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;