Skip to content

Commit 0225326

Browse files
entendumustangostang
authored andcommitted
Spyc.php fails to account for negative PHP_INT_MAX
While detecting the int type, spyc properly checks if the numerical value exceeds PHP_INT_MAX. However, it fails to account for the negative limit, so numbers less than (for example) the 64-bit limit of `-9223372036854775808` get clobbered into the limit.
1 parent 7f435f4 commit 0225326

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Spyc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ private function _toType($value) {
667667

668668
if ( is_numeric($value) && preg_match ('/^(-|)[1-9]+[0-9]*$/', $value) ){
669669
$intvalue = (int)$value;
670-
if ($intvalue != PHP_INT_MAX)
670+
if ($intvalue != PHP_INT_MAX && $intvalue != ~PHP_INT_MAX)
671671
$value = $intvalue;
672672
return $value;
673673
}

0 commit comments

Comments
 (0)