develooper Front page | perl.perl5.porters | Postings from February 2015

[perl #123946] assert in /\p^ /

Thread Previous | Thread Next
From:
Hugo van der Sanden via RT
Date:
February 27, 2015 10:05
Subject:
[perl #123946] assert in /\p^ /
Message ID:
rt-4.0.18-5948-1425031533-1503.123946-15-0@perl.org
On Thu Feb 26 17:52:20 2015, hv wrote:
> AFL (<http://lcamtuf.coredump.cx/afl/>) finds this:
> 
> % ./perl -Ilib -ce '/\p^ /'
> Use of uninitialized value $table in concatenation (.) or string at
> lib/utf8_heavy.pl line 398.
> Use of uninitialized value $_[0] in substitution (s///) at
> lib/utf8_heavy.pl line 23.
> Use of uninitialized value $loose in pattern match (m//) at
> lib/utf8_heavy.pl line 25.
> Use of uninitialized value $table in concatenation (.) or string at
> lib/utf8_heavy.pl line 409.
> perl: sv.c:11436: Perl_sv_vcatpvfn_flags: Assertion `(IV)elen >= 0'
> failed.
> Aborted (core dumped)
>  %
> 
> (I haven't yet looked at the utf8_heavy warnings, only the coredump.)

I now looked at the warnings: in SWASHNEW, we check $type is non-empty (in fact TRUE) before stripping whitespace; if it consists only of whitespace, we later end up with undef $property and $table. Either of the following one-line insertions seem to be enough to avoid the problem, but I'm not sure if either is actually the right thing - Karl, do you have an opinion on this?

In the above case, the initial $type is " \n".

Hugo

--- a/lib/utf8_heavy.pl
+++ b/lib/utf8_heavy.pl
@@ -119,6 +119,7 @@ sub _loose_name ($) {
 
             $type =~ s/^\s+//;
             $type =~ s/\s+$//;
+return $type unless length $type;
 
             # regcomp.c surrounds the property name with '__" and '_i' if this
             # is to be caseless matching.

--- a/lib/utf8_heavy.pl
+++ b/lib/utf8_heavy.pl
@@ -194,6 +194,7 @@ sub _loose_name ($) {
                 # value indicates the table we should use.
                 my ($property, $table, @remainder) =
                                     split /\s*[:=]\s*/, $property_and_table, -1
+$property //= "";
                 if (@remainder) {
                     pop @recursed if @recursed;
                     return $type;
(END)

---
via perlbug:  queue: perl5 status: new
https://rt.perl.org/Ticket/Display.html?id=123946

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About