gnucash master: [gnc-quotes] g_free a char* from gnc_prefs_get_string

Christopher Lam clam at code.gnucash.org
Sun Mar 19 12:42:05 EDT 2023


Updated	 via  https://github.com/Gnucash/gnucash/commit/97f06532 (commit)
	from  https://github.com/Gnucash/gnucash/commit/f9bb056d (commit)



commit 97f0653238425f38072b72aab280229d0afca025
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon Mar 20 00:38:15 2023 +0800

    [gnc-quotes] g_free a char* from gnc_prefs_get_string
    
    ultimately gets char* from g_settings_get_string and must be freed

diff --git a/libgnucash/app-utils/gnc-quotes.cpp b/libgnucash/app-utils/gnc-quotes.cpp
index e834089b38..227a042a34 100644
--- a/libgnucash/app-utils/gnc-quotes.cpp
+++ b/libgnucash/app-utils/gnc-quotes.cpp
@@ -178,10 +178,16 @@ m_version{}, m_sources{}, m_api_key{}
 
     auto av_key = gnc_prefs_get_string ("general.finance-quote", "alphavantage-api-key");
     if (!(av_key && *av_key))
+    {
+        g_free (av_key);
         av_key = getenv("ALPHAVANTAGE_API_KEY");
+    }
 
     if (av_key)
+    {
         m_api_key = std::string(av_key);
+        g_free (av_key);
+    }
     else
         PWARN("No Alpha Vantage API key set, currency quotes and other AlphaVantage based quotes won't work.");
 }



Summary of changes:
 libgnucash/app-utils/gnc-quotes.cpp | 6 ++++++
 1 file changed, 6 insertions(+)



More information about the gnucash-changes mailing list