From 4ffeb3efac85cd1650f33fb4acd0665936307213 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Wed, 28 Nov 2018 15:40:21 +0900 Subject: [PATCH] Ensure that a dereferenced variable isn't NULL. Found by clang static analyzer. --- libgnucash/engine/Transaction.c | 2 +- libgnucash/engine/qofquery.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libgnucash/engine/Transaction.c b/libgnucash/engine/Transaction.c index 355ccb06d9..866fc1fb59 100644 --- a/libgnucash/engine/Transaction.c +++ b/libgnucash/engine/Transaction.c @@ -1752,7 +1752,7 @@ xaccTransRollbackEdit (Transaction *trans) if (!qof_instance_is_dirty(QOF_INSTANCE(s))) continue; - if (i < num_preexist) + if (i < num_preexist && onode) { Split *so = onode->data; diff --git a/libgnucash/engine/qofquery.cpp b/libgnucash/engine/qofquery.cpp index f91d20487f..92c9719d40 100644 --- a/libgnucash/engine/qofquery.cpp +++ b/libgnucash/engine/qofquery.cpp @@ -486,7 +486,7 @@ compile_sort (QofQuerySort *sort, QofIdType obj) /* If we have valid parameters, grab the compare function, * If not, check if this is the default sort. */ - if (sort->param_fcns) + if (sort->param_fcns && resObj) { /* First, check if this parameter has a sort function override. * if not then check if there's a global compare function for the type @@ -535,7 +535,7 @@ static void compile_terms (QofQuery *q) * If not, see if this is the default sort. */ - if (qt->param_fcns) + if (qt->param_fcns && resObj) qt->pred_fcn = qof_query_core_get_predicate (resObj->param_type); else qt->pred_fcn = NULL;