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.
This commit is contained in:
Jakub Zelenka 2016-10-30 13:20:10 +00:00
parent be6bf71274
commit c34de0b61c
6 changed files with 120 additions and 47 deletions

View file

@ -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 */