Skip to content

Commit

Permalink
Spyc.php fails to account for negative PHP_INT_MAX
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
entendu authored and mustangostang committed Oct 21, 2016
1 parent 7f435f4 commit 0225326
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Spyc.php
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ private function _toType($value) {

if ( is_numeric($value) && preg_match ('/^(-|)[1-9]+[0-9]*$/', $value) ){
$intvalue = (int)$value;
if ($intvalue != PHP_INT_MAX)
if ($intvalue != PHP_INT_MAX && $intvalue != ~PHP_INT_MAX)
$value = $intvalue;
return $value;
}
Expand Down

0 comments on commit 0225326

Please # to comment.