From 022532641d61d383fd3ae666982bd46e61e5915e Mon Sep 17 00:00:00 2001 From: Domenic Santangelo Date: Sat, 18 Oct 2014 23:08:36 -0700 Subject: [PATCH] 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. --- Spyc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Spyc.php b/Spyc.php index c289bfe..f3d47c2 100644 --- a/Spyc.php +++ b/Spyc.php @@ -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; }