From 582265d0c6b3a499ca50a761633be02ad742c5cd Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Thu, 5 Jul 2018 19:37:41 +0800 Subject: [PATCH] [job-report] Prevent Crash if there is no AR account I think this crash is triggered because the 'account' variable defaults to the first available AR account. If there's no AR account it becomes null, and querying null's default book leads to segfault. I guess I can fix segfault too by fixing gnc_account_get_book. --- gnucash/report/business-reports/job-report.scm | 2 +- libgnucash/engine/Account.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/gnucash/report/business-reports/job-report.scm b/gnucash/report/business-reports/job-report.scm index 40b2bbfd51..e58f5a33d8 100644 --- a/gnucash/report/business-reports/job-report.scm +++ b/gnucash/report/business-reports/job-report.scm @@ -541,7 +541,7 @@ (end-date (gnc:time64-end-day-time (gnc:date-option-absolute-time (opt-val gnc:pagename-general (N_ "To"))))) - (book (gnc-account-get-book account)) + (book (gnc-get-current-book)) (date-format (gnc:options-fancy-date book)) (type (opt-val "__reg" "owner-type")) (type-str "") diff --git a/libgnucash/engine/Account.cpp b/libgnucash/engine/Account.cpp index a1144562a6..7920660cd3 100644 --- a/libgnucash/engine/Account.cpp +++ b/libgnucash/engine/Account.cpp @@ -1015,6 +1015,7 @@ xaccInitAccount (Account * acc, QofBook *book) QofBook * gnc_account_get_book(const Account *account) { + if (!account) return NULL; return qof_instance_get_book(QOF_INSTANCE(account)); }