[master] 4c9e068df ws: Forbid zero-length allocations
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Tue Aug 17 06:57:05 UTC 2021
commit 4c9e068df853d82024c78b6b39a88e07e5b0d9d0
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date: Wed Jul 7 12:20:51 2021 +0200
ws: Forbid zero-length allocations
Not even failing to allocate, but outright panicking.
diff --git a/bin/varnishd/cache/cache_ws.c b/bin/varnishd/cache/cache_ws.c
index a82f1aa1f..f8c491ebb 100644
--- a/bin/varnishd/cache/cache_ws.c
+++ b/bin/varnishd/cache/cache_ws.c
@@ -181,6 +181,7 @@ WS_Alloc(struct ws *ws, unsigned bytes)
char *r;
WS_Assert(ws);
+ assert(bytes > 0);
bytes = PRNDUP(bytes);
assert(ws->r == NULL);
@@ -206,7 +207,7 @@ WS_Copy(struct ws *ws, const void *str, int len)
if (len == -1)
len = strlen(str) + 1;
- assert(len >= 0);
+ assert(len > 0);
bytes = PRNDUP((unsigned)len);
if (ws->f + bytes > ws->e) {
More information about the varnish-commit
mailing list