Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Check config objects for NULL with reasonable default.
Vsevolod Stakhov committed 11 years ago
commit 680c5a3db60d82bd03bca03646bc1e3ba3a7fa71
parent e3eb7f3
1 file changed +4 -2
modified libpkg/pkg_object.c
@@ -89,7 +89,8 @@ pkg_object_type(const pkg_object *o)
bool
pkg_object_bool(const pkg_object *o)
{
-
	assert(o->type == UCL_BOOLEAN);
+
	if (o == NULL || o->type != UCL_BOOLEAN)
+
		return (false);

	return (ucl_object_toboolean(o));
}
@@ -112,7 +113,8 @@ pkg_object_string(const pkg_object *o)
int64_t
pkg_object_int(const pkg_object *o)
{
-
	assert(o->type == UCL_INT);
+
	if (o == NULL || o->type != UCL_INT)
+
		return (0);

	return (ucl_object_toint(o));
}