[master] 543e45e Add an assert to ensure we never go into a simple stevedore with a request for zero bytes.

Poul-Henning Kamp phk at FreeBSD.org
Tue Feb 23 11:07:44 CET 2016


commit 543e45e8a7dc69701e79837a71a3acb8526f68dc
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Feb 23 10:07:02 2016 +0000

    Add an assert to ensure we never go into a simple stevedore with
    a request for zero bytes.
    
    Suggested by:	github::onovy

diff --git a/bin/varnishd/storage/storage_simple.c b/bin/varnishd/storage/storage_simple.c
index 40e3b31..f985719 100644
--- a/bin/varnishd/storage/storage_simple.c
+++ b/bin/varnishd/storage/storage_simple.c
@@ -55,6 +55,7 @@ sml_stv_alloc(const struct stevedore *stv, size_t size)
 
 	for (;;) {
 		/* try to allocate from it */
+		assert(size > 0);
 		AN(stv->sml_alloc);
 		st = stv->sml_alloc(stv, size);
 		if (st != NULL)
@@ -132,6 +133,7 @@ SML_allocobj(struct worker *wrk, const struct stevedore *stv,
 				return (0);
 			really--;
 		}
+		AN(stv->sml_alloc);
 		st = stv->sml_alloc(stv, ltot);
 		if (st != NULL && st->space < ltot) {
 			stv->sml_free(st);
@@ -324,7 +326,6 @@ objallocwithnuke(struct worker *wrk, const struct stevedore *stv, size_t size)
 
 	for (fail = 0; fail <= cache_param->nuke_limit; fail++) {
 		/* try to allocate from it */
-		AN(stv->sml_alloc);
 		st = sml_stv_alloc(stv, size);
 		if (st != NULL)
 			break;



More information about the varnish-commit mailing list