[3.0] 5e2a759 Handle the case of sub being NULL

Tollef Fog Heen tfheen at varnish-cache.org
Mon Apr 16 10:20:37 CEST 2012


commit 5e2a759b85c0465542700a90a68a4943db382f49
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_vrt_re.c b/bin/varnishd/cache_vrt_re.c
index ec9801a..6eac0da 100644
--- a/bin/varnishd/cache_vrt_re.c
+++ b/bin/varnishd/cache_vrt_re.c
@@ -101,6 +101,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