]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix memleak in unit test, reported from the clang 8.0 static analyzer.
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Mon, 24 Jun 2019 08:53:27 +0000 (10:53 +0200)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Mon, 24 Jun 2019 08:53:27 +0000 (10:53 +0200)
doc/Changelog
testcode/memstats.c

index 2cb6d0124ecd87a0b4897efd69c52a8efe3bbd85..a5df4d5558b0d55e8b3dfc68849de5302acb64f2 100644 (file)
@@ -1,3 +1,6 @@
+24 June 2019: Wouter
+       - Fix memleak in unit test, reported from the clang 8.0 static analyzer.
+
 18 June 2019: Wouter
        - PR #28: IPSet module, by Kevin Chou.  Created a module to support
          the ipset that could add the domain's ip to a list easily.
index dc29058ad774783587018ee16f129559931a3036..a253b00ac506da8a32432a9a01185efc83e9ec09 100644 (file)
@@ -106,9 +106,16 @@ get_codeline(rbtree_type* tree, char* key, char* func)
                cl = calloc(1, sizeof(*cl));
                if(!cl) return 0;
                cl->codeline = strdup(key);
-               if(!cl->codeline) return 0;
+               if(!cl->codeline) {
+                       free(cl);
+                       return 0;
+               }
                cl->func = strdup(func);
-               if(!cl->func) return 0;
+               if(!cl->func) {
+                       free(cl->codeline);
+                       free(cl);
+                       return 0;
+               }
                cl->alloc = 0;
                cl->node.key = cl->codeline;
                (void)rbtree_insert(tree, &cl->node);