mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
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:
parent
be6bf71274
commit
c34de0b61c
6 changed files with 120 additions and 47 deletions
|
@ -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 */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue