From c34de0b61c68bd77e324b869760a53abead4c5ed Mon Sep 17 00:00:00 2001 From: Jakub Zelenka Date: Sun, 30 Oct 2016 13:20:10 +0000 Subject: Introduce json encoder to fix globals related issues It fixes bugs #66025 and #73254 by replacing globals with a passed structure holding depth and error code. In addition it fixes #72069 in a more generic way. --- ext/json/php_json_encoder.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'ext/json/php_json_encoder.h') diff --git a/ext/json/php_json_encoder.h b/ext/json/php_json_encoder.h index 0fec9174b5..68ce8b2de2 100644 --- a/ext/json/php_json_encoder.h +++ b/ext/json/php_json_encoder.h @@ -22,6 +22,19 @@ #include "php.h" #include "zend_smart_str.h" -int php_json_encode_zval(smart_str *buf, zval *val, int options); +typedef struct _php_json_encoder php_json_encoder; + +struct _php_json_encoder { + int depth; + int max_depth; + php_json_error_code error_code; +}; + +static inline void php_json_encode_init(php_json_encoder *encoder) +{ + memset(encoder, 0, sizeof(php_json_encoder)); +} + +int php_json_encode_zval(smart_str *buf, zval *val, int options, php_json_encoder *encoder); #endif /* PHP_JSON_ENCODER_H */ -- cgit v1.2.1