This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Storable: make count large enough
authorTony Cook <tony@develop-help.com>
Wed, 7 Aug 2019 01:13:53 +0000 (11:13 +1000)
committerTony Cook <tony@develop-help.com>
Wed, 7 Aug 2019 04:16:53 +0000 (14:16 +1000)
AvARRAY() could be very large, and we check for that at line 3807,
but int was (potentially) too small to make that comparison
meaningful.

CID 174681.

dist/Storable/Storable.xs

index 6a45d8a..d75125b 100644 (file)
@@ -3662,7 +3662,7 @@ static int store_hook(
     SV *ref;
     AV *av;
     SV **ary;
-    int count;                 /* really len3 + 1 */
+    IV count;                  /* really len3 + 1 */
     unsigned char flags;
     char *pv;
     int i;
@@ -3752,7 +3752,7 @@ static int store_hook(
     SvREFCNT_dec(ref);                 /* Reclaim temporary reference */
 
     count = AvFILLp(av) + 1;
-    TRACEME(("store_hook, array holds %d items", count));
+    TRACEME(("store_hook, array holds %" IVdf " items", count));
 
     /*
      * If they return an empty list, it means they wish to ignore the
@@ -3986,7 +3986,7 @@ static int store_hook(
      */
 
     TRACEME(("SX_HOOK (recursed=%d) flags=0x%x "
-             "class=%" IVdf " len=%" IVdf " len2=%" IVdf " len3=%d",
+             "class=%" IVdf " len=%" IVdf " len2=%" IVdf " len3=%" IVdf,
              recursed, flags, (IV)classnum, (IV)len, (IV)len2, count-1));
 
     /* SX_HOOK <flags> [<extra>] */