Commit 4c9e068d authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

ws: Forbid zero-length allocations

Not even failing to allocate, but outright panicking.
parent 46d9e79e
......@@ -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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment