From: Mark Andrews Date: Thu, 17 Jan 2013 03:38:28 +0000 (+1100) Subject: Silence "Access to field 'refs' results in a dereference of a null pointer" by adding... X-Git-Tag: v9.9.3-P1~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=72751ba1f86ea047a1a2bad4baad5ff499a4bb6d;p=thirdparty%2Fbind9.git Silence "Access to field 'refs' results in a dereference of a null pointer" by adding appropriate assertions. --- diff --git a/lib/isccfg/include/isccfg/cfg.h b/lib/isccfg/include/isccfg/cfg.h index f4677683446..9997c0697fb 100644 --- a/lib/isccfg/include/isccfg/cfg.h +++ b/lib/isccfg/include/isccfg/cfg.h @@ -411,6 +411,10 @@ cfg_obj_destroy(cfg_parser_t *pctx, cfg_obj_t **obj); /*%< * Delete a reference to a configuration object; destroy the object if * there are no more references. + * + * Require: + * \li '*obj' is a valid cfg_obj_t. + * \li 'pctx' is a valid cfg_parser_t. */ void diff --git a/lib/isccfg/parser.c b/lib/isccfg/parser.c index ef20184f397..b56b0d59b61 100644 --- a/lib/isccfg/parser.c +++ b/lib/isccfg/parser.c @@ -2426,9 +2426,14 @@ 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; unsigned int refs; + REQUIRE(objp != NULL && *objp != NULL); + REQUIRE(pctx != NULL); + + obj = *objp; + isc_refcount_decrement(&obj->references, &refs); if (refs == 0) { obj->type->rep->free(pctx, obj);