From f1b9163c7c8f71c833b21974975a15444cd5e24a Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Wed, 13 Jan 2021 10:23:56 +0100 Subject: [PATCH] fix php_stream_memory_open usage with 8.1+ --- src/php_http_message_body.c | 9 ++++----- src/php_http_misc.h | 5 +++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/php_http_message_body.c b/src/php_http_message_body.c index ad8a2b1..70fd587 100644 --- a/src/php_http_message_body.c +++ b/src/php_http_message_body.c @@ -420,7 +420,7 @@ static ZEND_RESULT_CODE add_recursive_files(php_http_message_body_t *body, const } else { zend_string *tmp = zval_get_string(zdata); - stream = php_stream_memory_open(TEMP_STREAM_READONLY, tmp->val, tmp->len); + stream = php_http_mem_stream_open(TEMP_STREAM_READONLY, tmp); zend_string_release(tmp); } } else { @@ -693,12 +693,11 @@ ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessageBody_unserialize, 0, 0, 1) ZEND_END_ARG_INFO(); PHP_METHOD(HttpMessageBody, unserialize) { - char *us_str; - size_t us_len; + zend_string *us_str; - if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "s", &us_str, &us_len)) { + if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "S", &us_str)) { php_http_message_body_object_t *obj = PHP_HTTP_OBJ(NULL, getThis()); - php_stream *s = php_stream_memory_open(0, us_str, us_len); + php_stream *s = php_http_mem_stream_open(0, us_str); obj->body = php_http_message_body_init(NULL, s); php_stream_to_zval(s, obj->gc); diff --git a/src/php_http_misc.h b/src/php_http_misc.h index 99660ea..481fb8c 100644 --- a/src/php_http_misc.h +++ b/src/php_http_misc.h @@ -102,6 +102,11 @@ static inline const char *php_http_locate_bin_eol(const char *bin, size_t len, i # define HASH_OF(p) ((HashTable*)(Z_TYPE_P(p)==IS_ARRAY ? Z_ARRVAL_P(p) : ((Z_TYPE_P(p)==IS_OBJECT ? Z_OBJ_HT_P(p)->get_properties(Z_OBJ_P(p)) : NULL)))) #endif +#if PHP_VERSION_ID >= 80100 +# define php_http_mem_stream_open(type, zstr) php_stream_memory_open((type), (zstr)) +#else +# define php_http_mem_stream_open(type, zstr) php_stream_memory_open((type), (zstr)->val, (zstr)->len) +#endif #define HT_IS_RECURSIVE(ht) GC_IS_RECURSIVE(ht) #define HT_PROTECT_RECURSION(ht) GC_PROTECT_RECURSION(ht) -- 2.30.2