This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #92432] Storable::nfreeze shouldn't stringify ints
authorSam Kimbrel <kimbrel@me.com>
Tue, 21 Jun 2011 05:24:42 +0000 (22:24 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Tue, 21 Jun 2011 15:21:57 +0000 (08:21 -0700)
commit41c44503bb87b01beab47665479128c346a4814d
treea63942da65bf1203b0ef01d246d9c085107fdad5
parent34e9d84f94ff5e9d44688751feed5a0a7299507c
[perl #92432] Storable::nfreeze shouldn't stringify ints

Storable::nfreeze's integer size check doesn't work correctly:

Using nfreeze to store an int larger than one byte produces a
frozen representation that thaws into a stringified integer, without
my having done string operations on the scalar beforehand.

I've confirmed this bug with the three versions I had available to me:
5.8.9 on 64-bit CentOS 4, 5.12.1 on 64-bit OS X 10.6, and
5.14.0 on 64-bit Debian squeeze.

The constants involved in the comparisons get created as 32-bit integers,
which wrap around and cause the comparison to yield true when it shouldn't.

This patch casts the constants before using them, which should make this
port correctly to 64-bit architectures. Running tests on a 64-bit Debian
host shows no problems.
dist/Storable/Storable.xs