From fe526a6043459763dba2701ff74fdb7717e193e4 Mon Sep 17 00:00:00 2001 From: Simon Arlott Date: Sat, 24 Jun 2023 11:49:29 +0100 Subject: [PATCH] Check source parameter to GncQuotesImpl::report() is not null The "source" parameter is checked once at the start before using strcmp() but is then used later on in GncQuotesImpl::query_fq() with function calls that can't handle null values. --- libgnucash/app-utils/gnc-quotes.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libgnucash/app-utils/gnc-quotes.cpp b/libgnucash/app-utils/gnc-quotes.cpp index 1b8246cf2e..9d97c2a9ad 100644 --- a/libgnucash/app-utils/gnc-quotes.cpp +++ b/libgnucash/app-utils/gnc-quotes.cpp @@ -329,7 +329,10 @@ void GncQuotesImpl::report (const char* source, const StrVec& commodities, bool verbose) { - bool is_currency{source && strcmp(source, "currency") == 0}; + if (!source) + throw (GncQuoteException(bl::translate("GncQuotes::Report called with no source."))); + + bool is_currency{strcmp(source, "currency") == 0}; m_failures.clear(); if (commodities.empty()) {