From: Alan T. DeKok Date: Mon, 30 Jul 2012 16:48:20 +0000 (+0200) Subject: Check for NULL parameters to functions X-Git-Tag: release_2_2_0~84 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=90092ce749e7e7d13e5cc0f16518b4a5d3d8a9ff;p=thirdparty%2Ffreeradius-server.git Check for NULL parameters to functions --- diff --git a/src/main/conffile.c b/src/main/conffile.c index d424f5ff6a7..95d4339e6a7 100644 --- a/src/main/conffile.c +++ b/src/main/conffile.c @@ -489,6 +489,8 @@ int cf_pair_replace(CONF_SECTION *cs, CONF_PAIR *cp, const char *value) */ static void cf_item_add(CONF_SECTION *cs, CONF_ITEM *ci) { + if (!cs || !ci) return; + if (!cs->children) { rad_assert(cs->tail == NULL); cs->children = ci; @@ -687,6 +689,8 @@ no_such_item: CONF_SECTION *cf_top_section(CONF_SECTION *cs) { + if (!cs) return NULL; + while (cs->item.parent != NULL) { cs = cs->item.parent; } @@ -1050,6 +1054,7 @@ int cf_item_parse(CONF_SECTION *cs, const char *name, CONF_PAIR *cpn; cpn = cf_pair_alloc(name, value, T_OP_SET, T_BARE_WORD, cs); + if (!cpn) return -1; cpn->item.filename = ""; cpn->item.lineno = 0; cf_item_add(cs, cf_pairtoitem(cpn));