[master] dea05fa4a Polish VRY_Finish()
Nils Goroll
nils.goroll at uplex.de
Mon Oct 3 14:30:07 UTC 2022
commit dea05fa4a855140cd807f75dccfa196b4099fa1a
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Thu Sep 1 14:02:17 2022 +0200
Polish VRY_Finish()
Assert on the return value of VRY_Validate() and call it only once.
(I would like to think that we can trust memcpy())
diff --git a/bin/varnishd/cache/cache_vary.c b/bin/varnishd/cache/cache_vary.c
index 2e461ab0e..1edc80436 100644
--- a/bin/varnishd/cache/cache_vary.c
+++ b/bin/varnishd/cache/cache_vary.c
@@ -259,6 +259,7 @@ void
VRY_Finish(struct req *req, enum vry_finish_flag flg)
{
uint8_t *p = NULL;
+ size_t l;
if (req->vary_b + 2 >= req->vary_e) {
AZ(req->vary_l);
@@ -269,13 +270,12 @@ VRY_Finish(struct req *req, enum vry_finish_flag flg)
return;
}
- (void)VRY_Validate(req->vary_b);
+ l = VRY_Validate(req->vary_b);
if (flg == KEEP && req->vary_l != NULL) {
- p = malloc(req->vary_l - req->vary_b);
- if (p != NULL) {
- memcpy(p, req->vary_b, req->vary_l - req->vary_b);
- (void)VRY_Validate(p);
- }
+ assert(l == req->vary_l - req->vary_b);
+ p = malloc(l);
+ if (p != NULL)
+ memcpy(p, req->vary_b, l);
}
WS_Release(req->ws, 0);
req->vary_l = NULL;
More information about the varnish-commit
mailing list