Silence "Access to field 'type' results in a dereference of a null pointer" by adding appropriate assertions.

This commit is contained in:
Mark Andrews
2013-01-17 14:38:28 +11:00
parent 4c43678e8e
commit f7d9efd98b
2 changed files with 10 additions and 1 deletions

View File

@@ -395,6 +395,10 @@ cfg_obj_istype(const cfg_obj_t *obj, const cfg_type_t *type);
void cfg_obj_destroy(cfg_parser_t *pctx, cfg_obj_t **obj);
/*%<
* Destroy a configuration object.
*
* Require:
* \li '*obj' is a valid cfg_obj_t.
* \li 'pctx' is a valid cfg_parser_t.
*/
void

View File

@@ -2390,7 +2390,12 @@ cfg_obj_istype(const cfg_obj_t *obj, const cfg_type_t *type) {
*/
void
cfg_obj_destroy(cfg_parser_t *pctx, cfg_obj_t **objp) {
cfg_obj_t *obj = *objp;
cfg_obj_t *obj;
REQUIRE(objp != NULL && *objp != NULL);
REQUIRE(pctx != NULL);
obj = *objp;
obj->type->rep->free(pctx, obj);
isc_mem_put(pctx->mctx, obj, sizeof(cfg_obj_t));
*objp = NULL;