Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clang static analyzer fixes #527

Merged
merged 3 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions http/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,12 @@ gotheaders(struct http_cookie * H, uint8_t * buf, size_t buflen)
H->res_headlen - bufpos);
}

/*
* We only call gotheaders() if we've found "\r\n\r\n", so we must have
* at least two EOLs.
*/
assert(H->res.nheaders >= 2);

/* # headers = # lines - 1 (status-line) - 1 (blank line). */
H->res.nheaders -= 2;

Expand Down
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
2 changes: 1 addition & 1 deletion util/daemonize.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ daemonize(const char * spid)
* releasing them for the benefit of leak checkers.
*/
if (ipc_sync_done(IS))
goto err1;
goto err0;

/* We have been poked by the child. Exit. */
_exit(0);
Expand Down
Loading