Skip to content

Commit

Permalink
Defer calling the bl::format::str()'s c-str() until point of use.
Browse files Browse the repository at this point in the history
Otherwise the string is a temporary that gets destructed at the end
of the statement and passing the char* to gnc_update_splash_screen
is a use-after-free.

Fixes macOS CI.
  • Loading branch information
jralls committed Dec 22, 2022
1 parent 0421ff8 commit 80c015d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions gnucash/gnucash.cpp
Expand Up @@ -176,11 +176,11 @@ scm_run_gnucash (void *data, [[maybe_unused]] int argc, [[maybe_unused]] char **
const auto checking = _("Checking Finance::Quote...");
gnc_update_splash_screen (checking, GNC_SPLASH_PERCENTAGE_UNKNOWN);
GncQuotes quotes;
auto found = (bl::format (std::string{_("Found Finance::Quote version {1}.")}) % quotes.version()).str().c_str();
auto found = (bl::format (std::string{_("Found Finance::Quote version {1}.")}) % quotes.version()).str();
auto quote_sources = quotes.sources_as_glist();
gnc_quote_source_set_fq_installed (quotes.version().c_str(), quote_sources);
g_list_free (quote_sources);
gnc_update_splash_screen (found, GNC_SPLASH_PERCENTAGE_UNKNOWN);
gnc_update_splash_screen (found.c_str(), GNC_SPLASH_PERCENTAGE_UNKNOWN);
}
catch (const GncQuoteException& err)
{
Expand Down

0 comments on commit 80c015d

Please sign in to comment.