Skip to content

Commit 9e5f687

Browse files
committed
Fix json object decoding
1 parent c6d0905 commit 9e5f687

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

ext/json/json_parser.y

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,11 @@ php_json_error_code php_json_parser_error_code(php_json_parser *parser)
176176
void php_json_parser_object_init(php_json_parser *parser, zval *object)
177177
{
178178
TSRMLS_FETCH_FROM_CTX(parser->zts_ctx);
179-
object_init(object);
179+
if (parser->scanner.options & PHP_JSON_OBJECT_AS_ARRAY) {
180+
array_init(object);
181+
} else {
182+
object_init(object);
183+
}
180184
}
181185

182186
void php_json_parser_object_update(php_json_parser *parser, zval *object, zval *zkey, zval *zvalue)
@@ -190,18 +194,17 @@ void php_json_parser_object_update(php_json_parser *parser, zval *object, zval *
190194
} else {
191195
if (key_len == 0) {
192196
key = "_empty_";
193-
key_len = sizeof("_empty_");
197+
key_len = sizeof("_empty_") - 1;
194198
}
195199
add_property_zval_ex(object, key, key_len, zvalue TSRMLS_CC);
196-
/*
200+
197201
if (Z_REFCOUNTED_P(zvalue)) {
198202
Z_DELREF_P(zvalue);
199203
}
200-
*/
201204
}
205+
zval_dtor(zkey);
202206
}
203207

204-
205208
void php_json_parser_array_init(zval *array)
206209
{
207210
array_init(array);

0 commit comments

Comments
 (0)