Permalink
Browse files

[perl #90160] U* gives ‘U0 mode on an empty string’

This is a regression in 5.10 caused by change 23966/08ca2aa38a29,
which added a bit of faulty logic. It was treating U* in the middle of
a pack template as equivalent to U0, if the input string was empty.
  • Loading branch information...
1 parent 3194a40 commit c5333953a555847ef4f1457905bf0f111a79eb72 Father Chrysostomos committed May 18, 2011
Showing with 6 additions and 2 deletions.
  1. +1 −1 pp_pack.c
  2. +5 −1 t/op/pack.t
View
@@ -1660,7 +1660,7 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c
break;
case 'U':
if (len == 0) {
- if (explicit_length) {
+ if (explicit_length && howlen != e_star) {
/* Switch to "bytes in UTF-8" mode */
if (symptr->flags & FLAG_DO_UTF8) utf8 = 0;
else
View
@@ -12,7 +12,7 @@ my $no_endianness = $] > 5.009 ? '' :
my $no_signedness = $] > 5.009 ? '' :
"Signed/unsigned pack modifiers not available on this perl";
-plan tests => 14699;
+plan tests => 14700;
use strict;
use warnings qw(FATAL all);
@@ -1993,3 +1993,7 @@ is(unpack('c'), 65, "one-arg unpack (change #18751)"); # defaulting to $_
my $y = runperl( prog => 'print split( /,/, unpack(q(%32u*), q(#,3,Q)), qq(\n)), qq(\n)' );
is($y, "0\n", "split /a/, unpack('%32u*'...) didn't crash");
}
+
+#90160
+is(eval { () = unpack "C0 U*", ""; "ok" }, "ok",
+ 'medial U* on empty string');

0 comments on commit c533395

Please sign in to comment.