summaryrefslogtreecommitdiff
path: root/hv.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2018-11-21 12:09:45 +0000
committerDavid Mitchell <davem@iabyn.com>2018-11-21 12:09:45 +0000
commit9ba9a28aaea66bad2de041880a2c4210a911dda6 (patch)
tree0e15fdfff99a1c95fb771be734d4616f94aa0223 /hv.c
parent59592778585db09866cbb37a7ab04eefc07b4df4 (diff)
downloadperl-9ba9a28aaea66bad2de041880a2c4210a911dda6.tar.gz
S_hv_delete_common(): avoid undefined behaviour
ASAN -fsanitize-undefined was tripping on the second of these two lines: svp = AvARRAY(isa); end = svp + AvFILLp(isa)+1; In the case where svp is NULL and AvFILLp(isa) is -1, the first addition is undefined behaviour. Add the 1 first, so that it becomes svp + (-1+1), which is safe.
Diffstat (limited to 'hv.c')
-rw-r--r--hv.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/hv.c b/hv.c
index d3d02d1046..fc90a5146b 100644
--- a/hv.c
+++ b/hv.c
@@ -1295,7 +1295,7 @@ S_hv_delete_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
SV **svp, **end;
strip_magic:
svp = AvARRAY(isa);
- end = svp + AvFILLp(isa)+1;
+ end = svp + (AvFILLp(isa)+1);
while (svp < end) {
if (*svp)
mg_free_type(*svp, PERL_MAGIC_isaelem);