[easytag] Avoid a use-after-free when caplitalizing words



commit 0ff9da52c747e848a7c323c2e7a585386614f69d
Author: David King <amigadave amigadave com>
Date:   Sat Apr 19 10:16:08 2014 +0100

    Avoid a use-after-free when caplitalizing words
    
    https://bugzilla.gnome.org/show_bug.cgi?id=728533

 src/easytag.c     |    2 +-
 src/scan_dialog.c |   12 ++++++++----
 src/scan_dialog.h |    2 +-
 3 files changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/src/easytag.c b/src/easytag.c
index 14d24c2..3a04df0 100644
--- a/src/easytag.c
+++ b/src/easytag.c
@@ -4329,7 +4329,7 @@ Convert_First_Letters_Uppercase (GtkWidget *entry)
 {
     gchar *string = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
 
-    Scan_Process_Fields_First_Letters_Uppercase(string);
+    Scan_Process_Fields_First_Letters_Uppercase (&string);
     gtk_entry_set_text(GTK_ENTRY(entry),string);
     g_free(string);
 }
diff --git a/src/scan_dialog.c b/src/scan_dialog.c
index b9e175f..fe8cc00 100644
--- a/src/scan_dialog.c
+++ b/src/scan_dialog.c
@@ -1407,7 +1407,9 @@ Scan_Process_Fields_Functions (gchar **string)
     }
 
     if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ProcessFieldsFirstLettersUppercase)))
-        Scan_Process_Fields_First_Letters_Uppercase(*string);
+    {
+        Scan_Process_Fields_First_Letters_Uppercase (string);
+    }
 
     if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ProcessFieldsRemoveSpace)))
         Scan_Process_Fields_Remove_Space(*string);
@@ -1418,7 +1420,8 @@ Scan_Process_Fields_Functions (gchar **string)
  * Function to set the first letter of each word to uppercase, according the "Chicago Manual of Style" 
(http://www.docstyles.com/cmscrib.htm#Note2)
  * No needed to reallocate
  */
-void Scan_Process_Fields_First_Letters_Uppercase (gchar *string)
+void
+Scan_Process_Fields_First_Letters_Uppercase (gchar **str)
 {
 /**** DANIEL TEST *****
     gchar *iter;
@@ -1441,6 +1444,7 @@ void Scan_Process_Fields_First_Letters_Uppercase (gchar *string)
     }
 ****/
 /**** Barış Çiçek version ****/
+    gchar *string = *str;
     gchar *word, *word1, *word2, *temp;
     gint i, len;
     gchar utf8_character[6];
@@ -1480,8 +1484,8 @@ void Scan_Process_Fields_First_Letters_Uppercase (gchar *string)
     }
 
     temp = Scan_Process_Fields_All_Downcase (string);
-    g_free (string);
-    string = temp;
+    g_free (*str);
+    *str = string = temp;
 
     if (!g_utf8_validate(string,-1,NULL))
     {
diff --git a/src/scan_dialog.h b/src/scan_dialog.h
index 8dc8ef6..83ec928 100644
--- a/src/scan_dialog.h
+++ b/src/scan_dialog.h
@@ -60,7 +60,7 @@ void et_scan_show (GtkAction *action, gpointer user_data);
 
 void entry_check_rename_file_mask (GtkEntry *entry, gpointer user_data);
 
-void Scan_Process_Fields_First_Letters_Uppercase (gchar *string);
+void Scan_Process_Fields_First_Letters_Uppercase (gchar **str);
 
 void Init_ScannerWindow (void);
 void Open_ScannerWindow (gint scanner_type);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]