Commit 3d2d277a authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Don't allocate if we do not fit in the segment.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4199 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent e9aa5e4c
......@@ -892,7 +892,6 @@ smp_new_seg(struct smp_sc *sc)
} else {
sg->offset = sg2->offset + sg2->length;
assert(sg->offset < sc->mediasize);
assert(sg->offset + sg2->length < sc->mediasize);
}
sg->length = sc->aim_segl;
sg->length &= ~7;
......@@ -1093,6 +1092,10 @@ smp_alloc(struct stevedore *st, size_t size)
sg = sc->cur_seg;
/* XXX: size fit check */
if (sg->next_addr + sizeof *ss + size > sg->length) {
Lck_Unlock(&sc->mtx);
return (NULL);
}
AN(sg->next_addr);
ss = (void *)(sc->ptr + sg->next_addr);
sg->next_addr += size + sizeof *ss;
......
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