[master] c8485f8 Nitpicks
Per Buer
perbu at varnish-software.com
Mon Sep 22 11:05:49 CEST 2014
commit c8485f8dd6913338cefa92ee1dad597918f5bf17
Author: Per Buer <perbu at varnish-software.com>
Date: Mon Sep 22 11:00:51 2014 +0200
Nitpicks
diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc
index 455485a..ad832d1 100644
--- a/lib/libvmod_std/vmod.vcc
+++ b/lib/libvmod_std/vmod.vcc
@@ -210,10 +210,14 @@ Example
$Function STRING strstr(STRING, STRING)
Description
- Returns true if the second string is a substring of the first
+ Returns the substring if the second string is a substring of the first
string. Note that the comparison is case sensitive. You can
use the tolower function on both strings if you want case
insensitivity.
+
+ If there is no match a NULL pointer is returned which would
+ evaluate to false in an if-test.
+
Example
if (std.strstr(req.url, req.http.x-restrict))
diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c
index 898e8dd..a3635e9 100644
--- a/lib/libvmod_std/vmod_std.c
+++ b/lib/libvmod_std/vmod_std.c
@@ -242,11 +242,12 @@ vmod_cache_req_body(const struct vrt_ctx *ctx, VCL_BYTES size)
VCL_STRING __match_proto__(td_std_strstr)
vmod_strstr(const struct vrt_ctx *ctx, VCL_STRING mstr, VCL_STRING msubstr)
-{
-
+{
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
- char *match = strstr(mstr, msubstr);
- return(match);
+ if ((mstr == NULL) || (msubstr == NULL))
+ return (NULL);
+ else
+ return(strstr(mstr, msubstr));
}
More information about the varnish-commit
mailing list