From 97f0653238425f38072b72aab280229d0afca025 Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Mon, 20 Mar 2023 00:38:15 +0800 Subject: [PATCH] [gnc-quotes] g_free a char* from gnc_prefs_get_string ultimately gets char* from g_settings_get_string and must be freed --- libgnucash/app-utils/gnc-quotes.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libgnucash/app-utils/gnc-quotes.cpp b/libgnucash/app-utils/gnc-quotes.cpp index e834089b38d..227a042a34b 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."); }