[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.
This commit is contained in:
Christopher Lam 2018-07-05 19:37:41 +08:00 committed by John Ralls
parent 0594beb081
commit 582265d0c6
2 changed files with 2 additions and 1 deletions

View File

@ -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 "")

View File

@ -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));
}