[master] a6c130649 Fix a newly introduced lifetime violation
Nils Goroll
nils.goroll at uplex.de
Mon Jan 31 17:22:07 UTC 2022
commit a6c1306494bab1d95fc7dd571089b80336922a1c
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Mon Jan 31 18:15:38 2022 +0100
Fix a newly introduced lifetime violation
TOSTRAND() creates a pointer with temporary lifetime which we must not
access outside of the expression where it is created.
Incidentally, this is what I had before a polish with good intentions,
which, as we all know, are not enough.
Noticed by Geoff, thank you
Ref ISO/IEC 9899:2018 §6.2.4 (8)
Ref 0c96fc6597c3ba6da057bb43acb7f677e6b776f8
diff --git a/vmod/vmod_vtc.c b/vmod/vmod_vtc.c
index 53387c7ee..ee2e5e8f2 100644
--- a/vmod/vmod_vtc.c
+++ b/vmod/vmod_vtc.c
@@ -439,7 +439,6 @@ vsl_line(VRT_CTX, char *str)
{
VCL_INT id;
VCL_ENUM side;
- VCL_STRANDS s;
const char *tag, *delim = " \t\r\n";
char *save;
@@ -469,11 +468,9 @@ vsl_line(VRT_CTX, char *str)
str = strtok_r(NULL, "\r\n", &save);
if (str == NULL)
- s = vrt_null_strands;
+ vmod_vsl(ctx, id, tag, side, vrt_null_strands);
else
- s = TOSTRAND(str);
-
- vmod_vsl(ctx, id, tag, side, s);
+ vmod_vsl(ctx, id, tag, side, TOSTRAND(str));
}
VCL_VOID
More information about the varnish-commit
mailing list