[PATCH] Fix memory leaks in scanner



The Scan_Process_Fields_First_Letters_Uppercase() uses g_utf8_strup in
roman numeral handling, but does not free the result.
---
 src/scan.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/scan.c b/src/scan.c
index 081be4f..db7d5bf 100644
--- a/src/scan.c
+++ b/src/scan.c
@@ -1550,7 +1550,9 @@ void Scan_Process_Fields_First_Letters_Uppercase (gchar *string)
     // If the word is a roman numeral, capitalize all of it
     if ((len = Scan_Word_Is_Roman_Numeral(temp)))
     {
-        strncpy(string, g_utf8_strup(temp, len), len);
+        gchar *tmp = g_utf8_strup(temp, len);
+        strncpy(string, tmp, len);
+        g_free(tmp);
     } else
     {
         // Set first character to uppercase
@@ -1588,7 +1590,9 @@ void Scan_Process_Fields_First_Letters_Uppercase (gchar *string)
         // If the word is a roman numeral, capitalize all of it
         if ((len = Scan_Word_Is_Roman_Numeral(word)))
         {
-            strncpy(word, g_utf8_strup(word, len), len);
+            gchar *tmp = g_utf8_strup(temp, len);
+            strncpy(string, tmp, len);
+            g_free(tmp);
         } else
         {
             // Set uppercase the first character of this word
-- 
1.8.3.2



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