Skip to content

Commit

Permalink
Fix crash if gnucash-cli --quotes is passed a bad database name.
Browse files Browse the repository at this point in the history
cleanup_and_exit_with_failure doesn't exit anymore so we need
to return its error value instead of trying to keep using the
freed session.
  • Loading branch information
jralls committed Apr 4, 2023
1 parent efb24f0 commit bc1f5b8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions gnucash/gnucash-commands.cpp
Expand Up @@ -342,11 +342,11 @@ Gnucash::add_quotes (const bo_str& uri)

qof_session_begin(session, uri->c_str(), SESSION_NORMAL_OPEN);
if (qof_session_get_error(session) != ERR_BACKEND_NO_ERR)
cleanup_and_exit_with_failure (session);
return cleanup_and_exit_with_failure (session);

qof_session_load(session, NULL);
if (qof_session_get_error(session) != ERR_BACKEND_NO_ERR)
cleanup_and_exit_with_failure (session);
return cleanup_and_exit_with_failure (session);

try
{
Expand All @@ -365,7 +365,7 @@ Gnucash::add_quotes (const bo_str& uri)
}
qof_session_save(session, NULL);
if (qof_session_get_error(session) != ERR_BACKEND_NO_ERR)
cleanup_and_exit_with_failure (session);
return cleanup_and_exit_with_failure (session);

qof_session_destroy(session);
qof_event_resume();
Expand Down

0 comments on commit bc1f5b8

Please sign in to comment.