fix php_stream_memory_open usage with 8.1+
authorMichael Wallner <mike@php.net>
Wed, 13 Jan 2021 09:23:56 +0000 (10:23 +0100)
committerMichael Wallner <mike@php.net>
Wed, 13 Jan 2021 09:23:56 +0000 (10:23 +0100)
src/php_http_message_body.c
src/php_http_misc.h

index ad8a2b12f7827c80ffac690ae392d4c3ccc67ebc..70fd58741667fdd859ffa250d892fb44a91a9dd7 100644 (file)
@@ -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);
index 99660ea98ada5caf0ddc74105c3e72d0b60a17a7..481fb8c5b71b88a04c8258ff00750196864a6efa 100644 (file)
@@ -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)