]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
1479. [bug] cfg_create_tuple() failed to handle out of
authorMark Andrews <marka@isc.org>
Thu, 3 Jul 2003 01:50:25 +0000 (01:50 +0000)
committerMark Andrews <marka@isc.org>
Thu, 3 Jul 2003 01:50:25 +0000 (01:50 +0000)
                        memory cleanup.  parse_list() would leak memory
                        on syntax errors.

CHANGES
lib/isccfg/parser.c

diff --git a/CHANGES b/CHANGES
index b48773d4557c4a960bb5abed0924ea744f14ab43..7c0c114e9a00be437217743e89d5f7694e18689a 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+1479.  [bug]           cfg_create_tuple() failed to handle out of
+                       memory cleanup.  parse_list() would leak memory
+                       on syntax errors.
+
 1478.  [port]          ifconfig.sh didn't account for other virtual
                        interfaces.  It now takes a optional arguement
                        to specify the first interface number. [RT #3907]
index 2c4e43557343f09e658ad16163030c5e3ec1396b..903c684d7aa1e1525530b3d58a6d12cfd28b42bb 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: parser.c,v 1.109 2003/07/03 00:43:28 marka Exp $ */
+/* $Id: parser.c,v 1.110 2003/07/03 01:50:25 marka Exp $ */
 
 #include <config.h>
 
@@ -216,7 +216,8 @@ cfg_create_tuple(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
        return (ISC_R_SUCCESS);
 
  cleanup:
-       CLEANUP_OBJ(obj);
+       if (obj != NULL)
+               isc_mem_put(pctx->mctx, obj, sizeof(*obj));
        return (result);
 }
 
@@ -973,24 +974,26 @@ parse_list(cfg_parser_t *pctx, const cfg_type_t *listtype, cfg_obj_t **ret)
        cfg_obj_t *listobj = NULL;
        const cfg_type_t *listof = listtype->of;
        isc_result_t result;
+       cfg_listelt_t *elt = NULL;
 
        CHECK(cfg_create_list(pctx, listtype, &listobj));
 
        for (;;) {
-               cfg_listelt_t *elt = NULL;
-
                CHECK(cfg_peektoken(pctx, 0));
                if (pctx->token.type == isc_tokentype_special &&
-                   pctx->token.value.as_char == '}')
+                   pctx->token.value.as_char == /*{*/ '}')
                        break;
                CHECK(cfg_parse_listelt(pctx, listof, &elt));
                CHECK(parse_semicolon(pctx));
                ISC_LIST_APPEND(listobj->value.list, elt, link);
+               elt = NULL;
        }
        *ret = listobj;
        return (ISC_R_SUCCESS);
 
  cleanup:
+       if (elt != NULL)
+               free_list_elt(pctx, elt);
        CLEANUP_OBJ(listobj);
        return (result);
 }
@@ -1303,7 +1306,6 @@ parse_symtab_elt(cfg_parser_t *pctx, const char *name,
        CHECK(isc_symtab_define(symtab, name,
                                1, symval,
                                isc_symexists_reject));
-       obj = NULL;
        return (ISC_R_SUCCESS);
 
  cleanup: