[master] 0a4884c6b VRT_blob() to return vrt_null_blob for empty blobs
Nils Goroll
nils.goroll at uplex.de
Wed Jun 2 13:37:05 UTC 2021
commit 0a4884c6b1bba370aa0fa3c1cdf6570fe82d539f
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Wed Jun 2 15:25:36 2021 +0200
VRT_blob() to return vrt_null_blob for empty blobs
diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index 7b334e4e2..d6f982b1d 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -1163,6 +1163,9 @@ VRT_blob(VRT_CTX, const char *err, const void *src, size_t len, unsigned type)
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ctx->ws, WS_MAGIC);
+ if (src == NULL || len == 0)
+ return (vrt_null_blob);
+
p = (void *)WS_Alloc(ctx->ws, sizeof *p);
if (p == NULL) {
VRT_fail(ctx, "Workspace overflow (%s)", err);
diff --git a/include/vrt.h b/include/vrt.h
index e2c3646c9..012d8a6ec 100644
--- a/include/vrt.h
+++ b/include/vrt.h
@@ -57,6 +57,8 @@
* vrt_null_strands added
* vrt_null_blob added
* VRT_NULL_BLOB_TYPE added as the .type of vrt_null_blob
+ * VRT_blob() changed to return vrt_null_blob for
+ * len == 0 or src == NULL arguments
* 13.0 (2021-03-15)
* Move VRT_synth_page() to deprecated status
* Add VRT_synth_strands() and VRT_synth_blob()
diff --git a/vmod/vmod_blob.c b/vmod/vmod_blob.c
index acf7469bd..98a1527cd 100644
--- a/vmod/vmod_blob.c
+++ b/vmod/vmod_blob.c
@@ -539,10 +539,6 @@ vmod_sub(VRT_CTX, VCL_BLOB b, VCL_BYTES n, VCL_BYTES off)
return (NULL);
}
- if (n == 0)
- return (vrt_null_blob);
-
-
return (VRT_blob(ctx, "blob.sub",
(const char *)b->blob + off, n, b->type));
}
More information about the varnish-commit
mailing list