gnucash stable: [gnc-report.cpp] Refinement to 1da2464577 -- *errmsg must be assigned

Christopher Lam clam at code.gnucash.org
Thu Dec 21 09:08:57 EST 2023


Updated	 via  https://github.com/Gnucash/gnucash/commit/5bcf979f (commit)
	from  https://github.com/Gnucash/gnucash/commit/cac01aae (commit)



commit 5bcf979f0b5be03b314931384d1553f08825b6e0
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Thu Dec 21 22:05:11 2023 +0800

    [gnc-report.cpp] Refinement to 1da2464577 -- *errmsg must be assigned
    
    Callers to this function expect that either *data or *errmsg are
    assigned a newly allocated char, to be g_freed later.

diff --git a/gnucash/report/gnc-report.cpp b/gnucash/report/gnc-report.cpp
index bd208fe96e..0e2ac18772 100644
--- a/gnucash/report/gnc-report.cpp
+++ b/gnucash/report/gnc-report.cpp
@@ -227,18 +227,12 @@ gnc_run_report_with_error_handling (gint report_id, gchar ** data, gchar **errms
         *errmsg = NULL;
         return TRUE;
     }
-    else if (scm_is_string (captured_error))
-    {
-        *errmsg = gnc_scm_to_utf8_string (captured_error);
-        *data = NULL;
-        PWARN ("Error in report: %s", *errmsg);
-        return FALSE;
-    }
     else
     {
+        *errmsg = scm_is_string (captured_error) ? gnc_scm_to_utf8_string (captured_error) :
+            g_strdup ("");
         *data = nullptr;
-        PWARN("Report %s Failed to generate html but didn't raise a Scheme exception.",
-              gnc_report_name (report));
+        PWARN ("Error in report: %s", *errmsg);
         return FALSE;
     }
 }



Summary of changes:
 gnucash/report/gnc-report.cpp | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)



More information about the gnucash-changes mailing list