Skip to content

Commit 341d2d1

Browse files
committed
Merge branch 'PHP-8.5'
* PHP-8.5: Fix GH-20771: Assertion failure when getUnicodeHost() returns empty string ext/session/mod_mm.c: add a few missing ZSTR macros
2 parents f80338c + 13d63d6 commit 341d2d1

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

ext/session/mod_mm.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ static void ps_mm_destroy(ps_mm *data)
264264

265265
PHP_MINIT_FUNCTION(ps_mm)
266266
{
267-
size_t save_path_len = strlen(PS(save_path));
267+
size_t save_path_len = ZSTR_LEN(PS(save_path));
268268
size_t mod_name_len = strlen(sapi_module.name);
269269
size_t euid_len;
270270
char *ps_mm_path, euid[30];
@@ -284,8 +284,8 @@ PHP_MINIT_FUNCTION(ps_mm)
284284
/* Directory + '/' + File + Module Name + Effective UID + \0 */
285285
ps_mm_path = emalloc(save_path_len + 1 + (sizeof(PS_MM_FILE) - 1) + mod_name_len + euid_len + 1);
286286

287-
memcpy(ps_mm_path, PS(save_path), save_path_len);
288-
if (save_path_len && PS(save_path)[save_path_len - 1] != DEFAULT_SLASH) {
287+
memcpy(ps_mm_path, ZSTR_VAL(PS(save_path)), save_path_len);
288+
if (save_path_len && ZSTR_VAL(PS(save_path))[save_path_len - 1] != DEFAULT_SLASH) {
289289
ps_mm_path[save_path_len] = DEFAULT_SLASH;
290290
save_path_len++;
291291
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
GH-20771 (Assertion failure when getUnicodeHost() returns empty string)
3+
--EXTENSIONS--
4+
uri
5+
--FILE--
6+
<?php
7+
8+
$url = Uri\WhatWg\Url::parse('test://');
9+
10+
var_dump($url->getUnicodeHost());
11+
12+
?>
13+
--EXPECT--
14+
string(0) ""

ext/uri/uri_parser_whatwg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ static zend_result php_uri_parser_whatwg_host_read(void *uri, php_uri_component_
365365
lxb_url_serialize_host_unicode(&lexbor_idna, &lexbor_uri->host, serialize_to_smart_str_callback, &host_str);
366366
lxb_unicode_idna_clean(&lexbor_idna);
367367

368-
ZVAL_NEW_STR(retval, smart_str_extract(&host_str));
368+
ZVAL_STR(retval, smart_str_extract(&host_str));
369369
break;
370370
}
371371
case PHP_URI_COMPONENT_READ_MODE_NORMALIZED_ASCII:

0 commit comments

Comments
 (0)