gnucash master: Multiple changes pushed
John Ralls
jralls at code.gnucash.org
Fri Mar 10 15:49:25 EST 2023
Updated via https://github.com/Gnucash/gnucash/commit/35dd8dbf (commit)
via https://github.com/Gnucash/gnucash/commit/329a2f7d (commit)
from https://github.com/Gnucash/gnucash/commit/58146dac (commit)
commit 35dd8dbf069e8e3e37e86f6f2b41ef59ea084bad
Merge: 58146dacce 329a2f7d42
Author: John Ralls <jralls at ceridwen.us>
Date: Fri Mar 10 12:48:51 2023 -0800
Merge Richard Cohen's 'guard-against-null-dereference' into master.
commit 329a2f7d4249c43e9baebd528b4ab3c3396d4e49
Author: Richard Cohen <richard at daijobu.co.uk>
Date: Thu Mar 2 12:31:03 2023 +0000
Guard against some possible null pointer dereferences
Found by gcc 12 when compiling with "-O2 -Wnull-dereference"
diff --git a/bindings/guile/gnc-kvp-guile.cpp b/bindings/guile/gnc-kvp-guile.cpp
index d1e011c185..c199ac68d6 100644
--- a/bindings/guile/gnc-kvp-guile.cpp
+++ b/bindings/guile/gnc-kvp-guile.cpp
@@ -121,7 +121,7 @@ gnc_kvp_value_ptr_to_scm(KvpValue* val)
case KvpValue::Type::GUID:
{
auto tempguid = val->get<GncGUID*>();
- return gnc_guid2scm(*tempguid);
+ return tempguid ? gnc_guid2scm(*tempguid) : SCM_BOOL_F;
}
break;
case KvpValue::Type::FRAME:
@@ -133,7 +133,7 @@ gnc_kvp_value_ptr_to_scm(KvpValue* val)
auto val_scm { gnc_kvp_value_ptr_to_scm (iter.second) };
return scm_acons (key_scm, val_scm, rv);
};
- return scm_reverse (std::accumulate (frame->begin(), frame->end(), SCM_EOL, acc));
+ return frame ? scm_reverse (std::accumulate (frame->begin(), frame->end(), SCM_EOL, acc)) : SCM_BOOL_F;
}
break;
case KvpValue::Type::GLIST:
diff --git a/gnucash/gnome-search/search-core-type.c b/gnucash/gnome-search/search-core-type.c
index 7d7ff38421..7ea04ab205 100644
--- a/gnucash/gnome-search/search-core-type.c
+++ b/gnucash/gnome-search/search-core-type.c
@@ -230,7 +230,9 @@ editable_enters (GNCSearchCoreType *fe)
void
gnc_search_core_register_type (const char *type_name, GNCSearchCoreNew fcn)
{
- g_return_if_fail (type_name || *type_name || fcn);
+ g_return_if_fail (type_name);
+ g_return_if_fail (*type_name);
+ g_return_if_fail (fcn);
g_return_if_fail (typeTable);
g_hash_table_insert (typeTable, (char *) type_name, (gpointer) fcn);
diff --git a/gnucash/gnome/gnc-plugin-page-owner-tree.c b/gnucash/gnome/gnc-plugin-page-owner-tree.c
index 80c4912f96..42d77ccdf6 100644
--- a/gnucash/gnome/gnc-plugin-page-owner-tree.c
+++ b/gnucash/gnome/gnc-plugin-page-owner-tree.c
@@ -932,7 +932,11 @@ static int build_owner_report (GncOwner *owner, Account *acc)
args = scm_cons (SCM_BOOL_F, args);
}
- arg = SWIG_NewPointerObj(owner, SWIG_TypeQuery("_p__gncOwner"), 0);
+ swig_type_info * qtype = SWIG_TypeQuery("_p__gncOwner");
+ g_return_val_if_fail (qtype, -1);
+
+ arg = SWIG_NewPointerObj(owner, qtype, 0);
+
g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
args = scm_cons (arg, args);
diff --git a/gnucash/report/gnc-report.cpp b/gnucash/report/gnc-report.cpp
index 33b4aa8220..e7b933675c 100644
--- a/gnucash/report/gnc-report.cpp
+++ b/gnucash/report/gnc-report.cpp
@@ -411,6 +411,9 @@ gnc_get_optiondb_from_dispatcher(SCM dispatcher)
else
c_ptr = reinterpret_cast<void*>(SCM_CELL_WORD_1(smob));
}
+ else
+ return nullptr;
+
auto u_ptr{static_cast<std::unique_ptr<GncOptionDB>*>(c_ptr)};
return u_ptr->get();
}
diff --git a/libgnucash/app-utils/calculation/expression_parser.c b/libgnucash/app-utils/calculation/expression_parser.c
index 3115217c7b..1c0a1559f8 100644
--- a/libgnucash/app-utils/calculation/expression_parser.c
+++ b/libgnucash/app-utils/calculation/expression_parser.c
@@ -612,8 +612,11 @@ parse_string (var_store_ptr value, const char *string, parser_env_ptr pe)
var_store_ptr val;
val = pop (pe);
- pe->negate_numeric (val->value);
- push (val, pe);
+ if (val)
+ {
+ pe->negate_numeric (val->value);
+ push (val, pe);
+ }
}
}
diff --git a/libgnucash/engine/gnc-date.cpp b/libgnucash/engine/gnc-date.cpp
index adf2600e7d..a2bdea6319 100644
--- a/libgnucash/engine/gnc-date.cpp
+++ b/libgnucash/engine/gnc-date.cpp
@@ -731,6 +731,8 @@ qof_scan_date_internal (const char *buff, int *day, int *month, int *year,
/* today's date */
gnc_time (&secs);
now = gnc_localtime (&secs);
+ if (!now)
+ return FALSE;
now_day = now->tm_mday;
now_month = now->tm_mon + 1;
now_year = now->tm_year + 1900;
diff --git a/libgnucash/engine/qofquery.cpp b/libgnucash/engine/qofquery.cpp
index a7f5b784d0..dacf105e05 100644
--- a/libgnucash/engine/qofquery.cpp
+++ b/libgnucash/engine/qofquery.cpp
@@ -1208,7 +1208,8 @@ qof_query_merge(QofQuery *q1, QofQuery *q2, QofQueryOp op)
break;
}
- retval->search_for = search_for;
+ if (retval)
+ retval->search_for = search_for;
return retval;
}
Summary of changes:
bindings/guile/gnc-kvp-guile.cpp | 4 ++--
gnucash/gnome-search/search-core-type.c | 4 +++-
gnucash/gnome/gnc-plugin-page-owner-tree.c | 6 +++++-
gnucash/report/gnc-report.cpp | 3 +++
libgnucash/app-utils/calculation/expression_parser.c | 7 +++++--
libgnucash/engine/gnc-date.cpp | 2 ++
libgnucash/engine/qofquery.cpp | 3 ++-
7 files changed, 22 insertions(+), 7 deletions(-)
More information about the gnucash-changes
mailing list