]> granicus.if.org Git - php/commitdiff
Merge branch 'PHP-5.6' into PHP-7.0
authorJakub Zelenka <bukka@php.net>
Sun, 14 Aug 2016 13:00:35 +0000 (14:00 +0100)
committerJakub Zelenka <bukka@php.net>
Sun, 14 Aug 2016 13:00:35 +0000 (14:00 +0100)
1  2 
ext/json/json.c

diff --cc ext/json/json.c
index 6571bf99f0e65aeffdbcb2bf4dc52278e4580f27,8c4d20fb2abf0d668ad6b7982379b317751b9aea..61445ee114a33e1e3d359620229168c94ece64bc
@@@ -253,13 -838,12 +253,23 @@@ static PHP_FUNCTION(json_decode
                return;
        }
  
 -      JSON_G(error_code) = 0;
 +      JSON_G(error_code) = PHP_JSON_ERROR_NONE;
  
        if (!str_len) {
 +              JSON_G(error_code) = PHP_JSON_ERROR_SYNTAX;
 +              RETURN_NULL();
 +      }
 +
++      if (depth <= 0) {
++              php_error_docref(NULL TSRMLS_CC, E_WARNING, "Depth must be greater than zero");
++              RETURN_NULL();
++      }
++
++      if (depth > INT_MAX) {
++              php_error_docref(NULL TSRMLS_CC, E_WARNING, "Depth must be lower than %d", INT_MAX);
+               RETURN_NULL();
+       }
        /* For BC reasons, the bool $assoc overrides the long $options bit for PHP_JSON_OBJECT_AS_ARRAY */
        if (assoc) {
                options |=  PHP_JSON_OBJECT_AS_ARRAY;