Commit 456ee023 authored by Geoff Simmons's avatar Geoff Simmons Committed by Pål Hermunn Johansen

add WS_Assert_Allocated: assert that ws->s <= a memory region < ws->f

Conflicts:
	bin/varnishd/cache/cache.h
	bin/varnishd/cache/cache_ws.c
parent 9f16b5ad
......@@ -1047,6 +1047,7 @@ void *WS_Copy(struct ws *ws, const void *str, int len);
char *WS_Snapshot(struct ws *ws);
int WS_Overflowed(const struct ws *ws);
void *WS_Printf(struct ws *ws, const char *fmt, ...) __v_printflike(2, 3);
void WS_Assert_Allocated(const struct ws *ws, const void *ptr, ssize_t len);
/* cache_rfc2616.c */
void RFC2616_Ttl(struct busyobj *, double now);
......
......@@ -59,6 +59,17 @@ WS_Assert(const struct ws *ws)
assert(*ws->e == 0x15);
}
void
WS_Assert_Allocated(const struct ws *ws, const void *ptr, ssize_t len)
{
const char *p = ptr;
WS_Assert(ws);
if (len < 0)
len = strlen(p) + 1;
assert(p >= ws->s && (p + len) < ws->f);
}
/*
* NB: The id must be max 3 char and lower-case.
* (upper-case the first char to indicate overflow)
......@@ -84,7 +95,6 @@ WS_Init(struct ws *ws, const char *id, void *space, unsigned len)
WS_Assert(ws);
}
void
WS_MarkOverflow(struct ws *ws)
{
......
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