gnucash maint: [import] Don't leak returns of g_utf8_normalize.

John Ralls jralls at code.gnucash.org
Sat Dec 17 18:38:19 EST 2022


Updated	 via  https://github.com/Gnucash/gnucash/commit/092d67eb (commit)
	from  https://github.com/Gnucash/gnucash/commit/9a8142ca (commit)



commit 092d67eb1afddcf7e9bcfa9358ff5d555de0383f
Author: John Ralls <jralls at ceridwen.us>
Date:   Sat Dec 17 15:38:03 2022 -0800

    [import] Don't leak returns of g_utf8_normalize.

diff --git a/gnucash/import-export/import-backend.c b/gnucash/import-export/import-backend.c
index d147af396..b59018fa6 100644
--- a/gnucash/import-export/import-backend.c
+++ b/gnucash/import-export/import-backend.c
@@ -862,22 +862,25 @@ notes_append (Transaction* selected_match_trans, gchar* new_notes)
 static char*
 maybe_append_string (const char* match_string, const char* imp_string)
 {
-    char *norm_match_string, *norm_imp_string;
+    char *norm_match_string, *norm_imp_string, *retval = NULL;
 
     if (!(match_string && *match_string))
         return g_strdup(imp_string);
 
     if (!(imp_string && *imp_string))
-        return NULL;
+        return retval;
 
     norm_match_string = g_utf8_normalize (match_string, -1, G_NORMALIZE_ALL);
     norm_imp_string = g_utf8_normalize (imp_string, -1, G_NORMALIZE_ALL);
 
     if (g_utf8_strlen (norm_imp_string, -1) > g_utf8_strlen (norm_match_string, -1) ||
          !strstr (norm_match_string, norm_imp_string))
-        return g_strconcat(match_string, "|", imp_string, NULL);
+        retval = g_strconcat(match_string, "|", imp_string, NULL);
+
+    g_free (norm_match_string);
+    g_free (norm_imp_string);
+    return retval;
 
-    return NULL;
 }
 
 /* Append or replace transaction description and notes



Summary of changes:
 gnucash/import-export/import-backend.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)



More information about the gnucash-changes mailing list