Skip to content

Commit 5426f9d

Browse files
committed
Fix memory leak with non interned string
1 parent 75ba014 commit 5426f9d

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

ext/standard/http.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ static void php_url_encode_object(zend_object *object, smart_str *form_str,
205205
num_prefix, num_prefix_len,
206206
NULL,
207207
arg_sep);
208+
zval_ptr_dtor(&tmp);
208209
}
209210
return;
210211
}

ext/standard/tests/http/http_build_query/http_build_query_object_just_stringable.phpt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,19 @@ class StringableObject {
1010

1111
$o = new StringableObject();
1212

13+
var_dump(http_build_query(['hello', $o]));
14+
var_dump(http_build_query($o));
15+
var_dump(http_build_query(['hello', $o], numeric_prefix: 'prefix_'));
16+
var_dump(http_build_query($o, numeric_prefix: 'prefix_'));
17+
18+
class StringableObjectWithNonInternedString {
19+
public function __toString() : string {
20+
return str_repeat("abcd", 3);
21+
}
22+
}
23+
24+
$o = new StringableObjectWithNonInternedString();
25+
1326
var_dump(http_build_query(['hello', $o]));
1427
var_dump(http_build_query($o));
1528
var_dump(http_build_query(['hello', $o], numeric_prefix: 'prefix_'));
@@ -20,3 +33,7 @@ string(20) "0=hello&1=Stringable"
2033
string(12) "0=Stringable"
2134
string(34) "prefix_0=hello&prefix_1=Stringable"
2235
string(19) "prefix_0=Stringable"
36+
string(22) "0=hello&1=abcdabcdabcd"
37+
string(14) "0=abcdabcdabcd"
38+
string(36) "prefix_0=hello&prefix_1=abcdabcdabcd"
39+
string(21) "prefix_0=abcdabcdabcd"

run-tests.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -857,13 +857,7 @@ function write_information(): void
857857
$php_cgi_info = '';
858858
}
859859

860-
if ($phpdbg) {
861-
$phpdbg_info = shell_exec("$phpdbg $pass_options $info_params $no_file_cache -qrr \"$info_file\"");
862-
$php_info_sep = "\n---------------------------------------------------------------------";
863-
$phpdbg_info = "$php_info_sep\nPHP : $phpdbg $phpdbg_info$php_info_sep";
864-
} else {
865-
$phpdbg_info = '';
866-
}
860+
$phpdbg_info = '';
867861

868862
if (function_exists('opcache_invalidate')) {
869863
opcache_invalidate($info_file, true);

0 commit comments

Comments
 (0)