Skip to content

Commit

Permalink
tests/heap: fix error paths
Browse files Browse the repository at this point in the history
Reported by:	clang19 scan-build
  • Loading branch information
gperciva committed Nov 26, 2024
1 parent 07ffcb3 commit 2884f38
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tests/heap/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ main(int argc, char * argv[])
if (strlen(s) != (size_t)l) {
warnp("Line of length %zu has embedded NUL: %s",
(size_t)l, s);
goto err0;
goto err1;
}

/* Remove trailing '\n'. */
Expand All @@ -55,13 +55,13 @@ main(int argc, char * argv[])
/* Duplicate string. */
if ((dups = strdup(s)) == NULL) {
warnp("strdup");
goto err0;
goto err2;
}

/* Insert string. */
if (ptrheap_add(H, dups)) {
warn0("ptrheap_add");
goto err0;
goto err2;
}
}

Expand All @@ -81,6 +81,10 @@ main(int argc, char * argv[])
/* Success! */
return (0);

err2:
free(s);
err1:
ptrheap_free(H);
err0:
/* Failure! */
return (1);
Expand Down

0 comments on commit 2884f38

Please sign in to comment.