MFH Fix bug #47644 - Valid integers are truncated with json_decode()

This commit is contained in:
Scott MacVicar 2009-03-17 02:00:13 +00:00
parent 1d5dbea704
commit 07e675cc52
2 changed files with 47 additions and 4 deletions

View file

@ -289,11 +289,11 @@ static void json_create_zval(zval **z, smart_str *buf, int type)
if (type == IS_LONG)
{
double d = zend_strtod(buf->c, NULL);
if (d > LONG_MAX || d < LONG_MIN) {
ZVAL_DOUBLE(*z, d);
long l = strtol(buf->c, NULL, 10);
if (l > LONG_MAX || l < LONG_MIN) {
ZVAL_DOUBLE(*z, zend_strtod(buf->c, NULL));
} else {
ZVAL_LONG(*z, (long)d);
ZVAL_LONG(*z, l);
}
}
else if (type == IS_DOUBLE)