diff options
author | Karl Williamson <khw@cpan.org> | 2019-04-05 16:21:51 -0600 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2019-04-05 17:14:11 -0600 |
commit | 45671da298df5eb367286a19e0b03796307902c9 (patch) | |
tree | 20ecb5c05880393718de5d8d7a7f920cdc3cb7d7 | |
parent | 9d5c52dfb15d17a41d63829964fdda6657054a13 (diff) | |
download | perl-45671da298df5eb367286a19e0b03796307902c9.tar.gz |
PATCH: [perl #133896] Assertion failure
This was due to UTF8_SAFE_SKIP(s, e) not allowing s to be as large as e,
and there are legitimate cases where it can be. This commit hardens the
macro so that it never reads above e-1, returning 0 if it otherwise
would be required to. The assertion is changed to 's <= e'.
-rw-r--r-- | t/re/reg_mesg.t | 1 | ||||
-rw-r--r-- | utf8.h | 11 |
2 files changed, 8 insertions, 4 deletions
diff --git a/t/re/reg_mesg.t b/t/re/reg_mesg.t index 9939646cbf..4a652ba6e4 100644 --- a/t/re/reg_mesg.t +++ b/t/re/reg_mesg.t @@ -316,6 +316,7 @@ my @death = '/[^/' => 'Unmatched [ {#} m/[{#}^/', # [perl #133767] '/\p{Is_Other_Alphabetic=F}/ ' => 'Can\'t find Unicode property definition "Is_Other_Alphabetic=F" {#} m/\p{Is_Other_Alphabetic=F}{#}/', '/\p{Is_Other_Alphabetic=F}/ ' => 'Can\'t find Unicode property definition "Is_Other_Alphabetic=F" {#} m/\p{Is_Other_Alphabetic=F}{#}/', + '/\x{100}(?(/' => 'Unknown switch condition (?(...)) {#} m/\\x{100}(?({#}/', # [perl #133896] ); # These are messages that are death under 'use re "strict"', and may or may @@ -501,13 +501,16 @@ only) byte is pointed to by C<s>. /* =for apidoc Am|STRLEN|UTF8_SAFE_SKIP|char* s|char* e -returns the number of bytes in the UTF-8 encoded character whose first (perhaps -only) byte is pointed to by C<s>. But never returns beyond C<e>. +returns 0 if S<C<s E<gt>= e>>; otherwise returns the number of bytes in the +UTF-8 encoded character whose first byte is pointed to by C<s>. But it never +returns beyond C<e>. On DEBUGGING builds, it asserts that S<C<s E<lt>= e>>. =cut */ -#define UTF8_SAFE_SKIP(s, e) (__ASSERT_((e) > (s)) \ - MIN(((e) - (s)), UTF8_SKIP(s))) +#define UTF8_SAFE_SKIP(s, e) (__ASSERT_((e) >= (s)) \ + ((e) - (s)) <= 0 \ + ? 0 \ + : MIN(((e) - (s)), UTF8_SKIP(s))) /* Most code that says 'UNI_' really means the native value for code points up * through 255 */ |