From: Klaus Ethgen Date: Sun, 21 Jun 2009 22:52:08 +0000 (+0000) Subject: Fix two memory failures X-Git-Tag: v1.0.0~142 X-Git-Url: http://geeqie.org/cgi-bin/gitweb.cgi?p=geeqie.git;a=commitdiff_plain;h=d820c538051df54a6316047a3da7ce77414fa980 Fix two memory failures 1. if the description field for a exif information is empty the program dumps core when trying to change this. The reason is a strcmp with a NULL value. The fix add the small functionality to set the field to default when it is set empty. 2. There was a g_strdup miss in exif.c which could end in memory corruption. --- diff --git a/src/bar_exif.c b/src/bar_exif.c index 47036744..ee6d1df1 100644 --- a/src/bar_exif.c +++ b/src/bar_exif.c @@ -494,7 +494,13 @@ static void bar_pane_exif_edit_ok_cb(GenericDialog *gd, gpointer data) g_free(ee->key); ee->key = g_strdup(gtk_entry_get_text(GTK_ENTRY(cdd->key_entry))); title = gtk_entry_get_text(GTK_ENTRY(cdd->title_entry)); - if (strcmp(ee->title, title) != 0) + if (!title || strlen(title) == 0) + { + g_free(ee->title); + ee->title = exif_get_description_by_key(ee->key); + ee->auto_title = TRUE; + } + else if (!ee->title || strcmp(ee->title, title) != 0) { g_free(ee->title); ee->title = g_strdup(title); diff --git a/src/exif.c b/src/exif.c index 7db7842c..ff98a8b4 100644 --- a/src/exif.c +++ b/src/exif.c @@ -1516,7 +1516,7 @@ gchar *exif_get_tag_description_by_key(const gchar *key) i = 0; while (ExifKnownGPSInfoMarkersList[i].tag > 0) { - if (strcmp(key, ExifKnownGPSInfoMarkersList[i].key) == 0) return _(ExifKnownGPSInfoMarkersList[i].description); + if (strcmp(key, ExifKnownGPSInfoMarkersList[i].key) == 0) return g_strdup(_(ExifKnownGPSInfoMarkersList[i].description)); i++; }