[master] 0802b1f Handle the case of sub being NULL

Tollef Fog Heen tfheen at varnish-cache.org
Wed Jan 11 14:07:42 CET 2012


commit 0802b1fe539325b44f316f3c598a6607638a83c0
Author: Tollef Fog Heen <tfheen at varnish-software.com>
Date:   Wed Jan 11 14:07:02 2012 +0100

    Handle the case of sub being NULL
    
    if sub is null (because it's the contents of a non-existing header),
    pretend it's "" instead.

diff --git a/bin/varnishd/cache/cache_vrt_re.c b/bin/varnishd/cache/cache_vrt_re.c
index 9864611..867ec86 100644
--- a/bin/varnishd/cache/cache_vrt_re.c
+++ b/bin/varnishd/cache/cache_vrt_re.c
@@ -96,6 +96,8 @@ VRT_regsub(const struct sess *sp, int all, const char *str, void *re,
 	AN(re);
 	if (str == NULL)
 		str = "";
+	if (sub == NULL)
+		sub = "";
 	t = re;
 	memset(ovector, 0, sizeof(ovector));
 	len = strlen(str);
diff --git a/bin/varnishtest/tests/c00001.vtc b/bin/varnishtest/tests/c00001.vtc
index d9b6c41..f1a6824 100644
--- a/bin/varnishtest/tests/c00001.vtc
+++ b/bin/varnishtest/tests/c00001.vtc
@@ -21,6 +21,8 @@ varnish v1 -vcl+backend {
 		    regsub(beresp.http.Foobar, "(b)(a)(r)(f)", "\0\4\3\2\\p");
 		set beresp.http.Snafu6 =
 		    regsub(beresp.http.Foobar, "(b)(a)(r)(f)", "\4\&\3\2p\");
+		set beresp.http.Snafu7 =
+		    regsub(beresp.http.Foobar, "ar", req.http.nosuchheader);
 	}
 } -start 
 
@@ -37,4 +39,5 @@ client c1 {
 	# NB: have to escape the \\ in the next two lines
 	expect resp.http.snafu5 == "_barffra\\p_"
 	expect resp.http.snafu6 == "_f&rap\\_"
+	expect resp.http.snafu7 == "_bf_"
 } -run



More information about the varnish-commit mailing list