diff --git a/desmume/src/gtk-glade/printscreen.cpp b/desmume/src/gtk-glade/printscreen.cpp index 0526cb0d1..63c564bda 100755 --- a/desmume/src/gtk-glade/printscreen.cpp +++ b/desmume/src/gtk-glade/printscreen.cpp @@ -66,6 +66,8 @@ int WriteBMP(const char *filename,u16 *bmp){ imageheader.height = 192*2; FILE *fichier = fopen(filename,"wb"); + if (!fichier) + return 0; //fwrite(&fileheader, 1, 14, fichier); //fwrite(&imageheader, 1, 40, fichier); diff --git a/desmume/src/gtk/gtk-compat.cpp b/desmume/src/gtk/gtk-compat.cpp index eba86609c..e1aae2dac 100644 --- a/desmume/src/gtk/gtk-compat.cpp +++ b/desmume/src/gtk/gtk-compat.cpp @@ -23,11 +23,16 @@ gboolean g_file_set_contents(const gchar * filename, const gchar * contents, gssize len, GError ** error) { FILE * file = fopen(filename, "w"); + if (!file) + return FALSE; + if (len == -1) fprintf(file, "%s", contents); else fwrite(contents, 1, len, file); fclose(file); + + return TRUE; } #endif diff --git a/desmume/src/gtk/main.cpp b/desmume/src/gtk/main.cpp index 0c1f571f2..94d94a836 100644 --- a/desmume/src/gtk/main.cpp +++ b/desmume/src/gtk/main.cpp @@ -293,6 +293,7 @@ static int Write_ConfigFile() int i; GKeyFile * keyfile; gchar *contents; + gboolean ret; keyfile = g_key_file_new(); @@ -307,7 +308,9 @@ static int Write_ConfigFile() // } contents = g_key_file_to_data(keyfile, 0, 0); - g_file_set_contents(CONFIG_FILE, contents, -1, 0); + ret = g_file_set_contents(CONFIG_FILE, contents, -1, NULL); + if (!ret) + fprintf(stderr, "Failed to write to %s\n", CONFIG_FILE); g_free (contents); g_key_file_free(keyfile); @@ -1190,6 +1193,8 @@ static int WriteBMP(const char *filename,u16 *bmp) imageheader.height = 192*2; FILE *fichier = fopen(filename,"wb"); + if (!fichier) + return 0; //fwrite(&fileheader, 1, 14, fichier); //fwrite(&imageheader, 1, 40, fichier);