summaryrefslogtreecommitdiff
path: root/toke.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2022-01-22 14:41:27 -0700
committerℕicolas ℝ <nicolas@atoomic.org>2022-02-02 08:43:27 -0700
commite1c60a5de80391903ce3f33e708d032cd2ba9b0a (patch)
tree1045bc386393d7617a7b58fc76ba1c01380bfd85 /toke.c
parenta460925186154b270b7a647a4f30b2f01fd97c4b (diff)
downloadperl-e1c60a5de80391903ce3f33e708d032cd2ba9b0a.tar.gz
toke.c: Fix potential C sign error
Taking (UV)(* char) isn't what was meant. Instead it should be (UV) * (U8 *)(char). (and the UV cast becomes irrelevant in this case). If the C compiler defaults char to unsigned, it doesn't matter. Nor does it matter if the char value is positive. But it gives the wrong result when 'char' means 'signed char' and the value is negative. Experimentally adding non-ASCII brackets to this code showed up this error.
Diffstat (limited to 'toke.c')
-rw-r--r--toke.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/toke.c b/toke.c
index 61a7e9e970..18e23e2c85 100644
--- a/toke.c
+++ b/toke.c
@@ -11473,9 +11473,9 @@ Perl_scan_str(pTHX_ char *start, int keep_bracketed_quoted, int keep_delims, int
*to++ = *s++;
}
/* allow nested opens and closes */
- else if ((UV)*s == PL_multi_close && --brackets <= 0)
+ else if (*(U8 *) s == PL_multi_close && --brackets <= 0)
break;
- else if ((UV)*s == PL_multi_open)
+ else if (*(U8 *) s == PL_multi_open)
brackets++;
else if (!d_is_utf8 && !UTF8_IS_INVARIANT((U8)*s) && UTF)
d_is_utf8 = TRUE;