This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
When probing strxfrm, consider a consistent return value of 0 as sane
authorNicholas Clark <nick@ccl4.org>
Fri, 9 Sep 2011 16:15:00 +0000 (18:15 +0200)
committerFlorian Ragwitz <rafl@debian.org>
Fri, 9 Sep 2011 16:15:00 +0000 (18:15 +0200)
locale.c

index 5893212..81c09ab 100644 (file)
--- a/locale.c
+++ b/locale.c
@@ -231,7 +231,7 @@ Perl_new_collate(pTHX_ const char *newcoll)
          const Size_t fa = strxfrm(xbuf, "a",  XFRMBUFSIZE);
          const Size_t fb = strxfrm(xbuf, "ab", XFRMBUFSIZE);
          const SSize_t mult = fb - fa;
-         if (mult < 1)
+         if (mult < 1 && !(fa == 0 && fb == 0))
              Perl_croak(aTHX_ "panic: strxfrm() gets absurd - a => %"UVuf", ab => %"UVuf,
                         (UV) fa, (UV) fb);
          PL_collxfrm_base = (fa > (Size_t)mult) ? (fa - mult) : 0;