projects
/
m6w6
/
ext-http
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
- Fixed memory leak when HttpUtil::Inflate() fails
[m6w6/ext-http]
/
http_querystring_api.c
diff --git
a/http_querystring_api.c
b/http_querystring_api.c
index 899715d6ebda9968b932d3ffe5e2724ebe9b7981..e6b557adc3f0d5248b3283d761f4734e047f1836 100644
(file)
--- a/
http_querystring_api.c
+++ b/
http_querystring_api.c
@@
-116,26
+116,25
@@
PHP_HTTP_API int _http_querystring_modify(zval *qarray, zval *params TSRMLS_DC)
return http_querystring_modify_array(qarray, params);
} else if (Z_TYPE_P(params) == IS_OBJECT) {
#ifdef ZEND_ENGINE_2
return http_querystring_modify_array(qarray, params);
} else if (Z_TYPE_P(params) == IS_OBJECT) {
#ifdef ZEND_ENGINE_2
- if (!instanceof_function(Z_OBJCE_P(params), http_querystring_object_ce TSRMLS_CC)) {
+ if (instanceof_function(Z_OBJCE_P(params), http_querystring_object_ce TSRMLS_CC)) {
+ return http_querystring_modify_array(qarray, zend_read_property(THIS_CE, params, ZEND_STRS("queryArray")-1, 0 TSRMLS_CC));
+ } else {
#endif
#endif
- zval temp_array;
- INIT_ZARR(temp_array, HASH_OF(params));
- return http_querystring_modify_array(qarray, &temp_array);
+ return http_querystring_modify_array(qarray, params);
#ifdef ZEND_ENGINE_2
}
#ifdef ZEND_ENGINE_2
}
- return http_querystring_modify_array(qarray, zend_read_property(THIS_CE, params, ZEND_STRS("queryArray")-1, 0 TSRMLS_CC));
#endif
} else {
int rv;
zval array;
#endif
} else {
int rv;
zval array;
+ zval *qstring = http_zsep(IS_STRING, params);
INIT_PZVAL(&array);
array_init(&array);
INIT_PZVAL(&array);
array_init(&array);
- ZVAL_ADDREF(params);
- convert_to_string_ex(¶ms);
- sapi_module.treat_data(PARSE_STRING, estrdup(Z_STRVAL_P(params)), &array TSRMLS_CC);
- zval_ptr_dtor(¶ms);
+ sapi_module.treat_data(PARSE_STRING, estrdup(Z_STRVAL_P(qstring)), &array TSRMLS_CC);
+ zval_ptr_dtor(&qstring);
+
rv = http_querystring_modify_array(qarray, &array);
zval_dtor(&array);
return rv;
rv = http_querystring_modify_array(qarray, &array);
zval_dtor(&array);
return rv;
@@
-149,7
+148,7
@@
static inline int _http_querystring_modify_array(zval *qarray, zval *params TSRM
HashPosition pos;
zval **params_entry = NULL;
HashPosition pos;
zval **params_entry = NULL;
- FOREACH_
KEYVAL(pos, params
, key, params_entry) {
+ FOREACH_
HASH_KEYVAL(pos, HASH_OF(params)
, key, params_entry) {
/* only public properties */
if ((key.type != HASH_KEY_IS_STRING || *key.str) && http_querystring_modify_array_ex(qarray, key.type, key.str, key.len, key.num, *params_entry)) {
rv = 1;
/* only public properties */
if ((key.type != HASH_KEY_IS_STRING || *key.str) && http_querystring_modify_array_ex(qarray, key.type, key.str, key.len, key.num, *params_entry)) {
rv = 1;
@@
-162,6
+161,11
@@
static inline int _http_querystring_modify_array(zval *qarray, zval *params TSRM
static inline int _http_querystring_modify_array_ex(zval *qarray, int key_type, char *key, int keylen, ulong idx, zval *params_entry TSRMLS_DC)
{
zval **qarray_entry;
static inline int _http_querystring_modify_array_ex(zval *qarray, int key_type, char *key, int keylen, ulong idx, zval *params_entry TSRMLS_DC)
{
zval **qarray_entry;
+
+ /* ensure array type */
+ if (Z_TYPE_P(qarray) != IS_ARRAY) {
+ convert_to_array(qarray);
+ }
/* delete */
if (Z_TYPE_P(params_entry) == IS_NULL) {
/* delete */
if (Z_TYPE_P(params_entry) == IS_NULL) {
@@
-188,9
+192,15
@@
static inline int _http_querystring_modify_array_ex(zval *qarray, int key_type,
}
/* add */
}
/* add */
- ZVAL_ADDREF(params_entry);
if (Z_TYPE_P(params_entry) == IS_OBJECT) {
if (Z_TYPE_P(params_entry) == IS_OBJECT) {
- convert_to_array_ex(¶ms_entry);
+ zval *new_array;
+
+ MAKE_STD_ZVAL(new_array);
+ array_init(new_array);
+ http_querystring_modify_array(new_array, params_entry);
+ params_entry = new_array;
+ } else {
+ ZVAL_ADDREF(params_entry);
}
if (key_type == HASH_KEY_IS_STRING) {
add_assoc_zval_ex(qarray, key, keylen, params_entry);
}
if (key_type == HASH_KEY_IS_STRING) {
add_assoc_zval_ex(qarray, key, keylen, params_entry);