- Fix memleak in unit test, reported from the clang 8.0 static analyzer.

This commit is contained in:
W.C.A. Wijngaards
2019-06-24 10:53:27 +02:00
parent 78b2f1cc20
commit 1aa1facabc
2 changed files with 12 additions and 2 deletions
+9 -2
View 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);