summaryrefslogtreecommitdiff
path: root/ext/json/php_json_encoder.h
diff options
context:
space:
mode:
authorJakub Zelenka <bukka@php.net>2016-10-30 13:20:10 +0000
committerJakub Zelenka <bukka@php.net>2016-10-30 13:20:10 +0000
commitc34de0b61c68bd77e324b869760a53abead4c5ed (patch)
tree54dc1cb22510d6c992e47f9fef7a78e1290fa85e /ext/json/php_json_encoder.h
parentbe6bf71274a4670d7c7f45142890eb0651359c64 (diff)
downloadphp-git-c34de0b61c68bd77e324b869760a53abead4c5ed.tar.gz
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.
Diffstat (limited to 'ext/json/php_json_encoder.h')
-rw-r--r--ext/json/php_json_encoder.h15
1 files changed, 14 insertions, 1 deletions
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 */