[master] 3fb23a2 Fix my typo that meant that we trampled on unowned memory.
Poul-Henning Kamp
phk at varnish-cache.org
Tue Oct 29 15:00:56 CET 2013
commit 3fb23a2edd675a5dd63d0fa0e591c036cd7cbed1
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue Oct 29 14:00:22 2013 +0000
Fix my typo that meant that we trampled on unowned memory.
Almost pinpointed by Martin using Valgrind.
diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c
index 886b3de..cdfcc9d 100644
--- a/bin/varnishd/cache/cache_session.c
+++ b/bin/varnishd/cache/cache_session.c
@@ -98,9 +98,10 @@ ses_new(struct sesspool *pp)
{
struct sess *sp;
char *s;
+ unsigned sz;
CHECK_OBJ_NOTNULL(pp, SESSPOOL_MAGIC);
- sp = MPL_Get(pp->mpl_sess, NULL);
+ sp = MPL_Get(pp->mpl_sess, &sz);
sp->magic = SESS_MAGIC;
sp->sesspool = pp;
@@ -109,6 +110,8 @@ ses_new(struct sesspool *pp)
s += vsa_suckaddr_len;
memset(s, 0, vsa_suckaddr_len);
sp->their_addr = (void*)s;
+ s += vsa_suckaddr_len;
+ assert((char *)sp + sz == s);
sp->t_open = NAN;
sp->t_idle = NAN;
diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index 1f58a1d..563b2bc 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -302,7 +302,7 @@ VRT_IP_string(const struct vrt_ctx *ctx, VCL_IP ip)
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
len = WS_Reserve(ctx->ws, 0);
- p = ctx->ws->r;
+ p = ctx->ws->f;
VTCP_name(ip, p, len, NULL, 0);
WS_Release(ctx->ws, strlen(p) + 1);
return (p);
More information about the varnish-commit
mailing list