From: W.C.A. Wijngaards Date: Mon, 24 Jun 2019 08:53:27 +0000 (+0200) Subject: - Fix memleak in unit test, reported from the clang 8.0 static analyzer. X-Git-Tag: release-1.9.3rc1~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1aa1facabc26b8cc6da3acec5e960983b72f5f2c;p=thirdparty%2Funbound.git - Fix memleak in unit test, reported from the clang 8.0 static analyzer. --- diff --git a/doc/Changelog b/doc/Changelog index 2cb6d0124..a5df4d555 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -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. diff --git a/testcode/memstats.c b/testcode/memstats.c index dc29058ad..a253b00ac 100644 --- a/testcode/memstats.c +++ b/testcode/memstats.c @@ -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);