Guard against some possible null pointer dereferences

Found by gcc 12 when compiling with "-O2 -Wnull-dereference"
This commit is contained in:
Richard Cohen
2023-03-02 12:31:03 +00:00
parent 7d5154ce18
commit 329a2f7d42
7 changed files with 22 additions and 7 deletions

View File

@@ -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: