Skip to content

Commit a69d0ba

Browse files
committed
Actually free persistent header value
Still don't understand why ASAN didn't pick this up, probably need to check with Valgrind
1 parent 5b53f0f commit a69d0ba

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

sapi/cli/php_cli_server.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,11 @@ static bool php_cli_server_get_system_time(char *buf) {
266266
}
267267
#endif
268268

269+
/* Destructor for php_cli_server_request->headers, this frees header value */
269270
static void char_ptr_dtor_p(zval *zv) /* {{{ */
270271
{
271-
pefree(Z_PTR_P(zv), 1);
272+
// TODO free have zend_string* not as a pointer
273+
zend_string_release_ex(Z_PTR_P(zv), /* persistent */ true);
272274
} /* }}} */
273275

274276
static char *get_last_error(void) /* {{{ */
@@ -1339,6 +1341,7 @@ static void php_cli_server_request_ctor(php_cli_server_request *req) /* {{{ */
13391341
req->query_string = NULL;
13401342
req->query_string_len = 0;
13411343
zend_hash_init(&req->headers, 0, NULL, char_ptr_dtor_p, 1);
1344+
/* No destructor is registered as the value pointed by is the same as for &req->headers */
13421345
zend_hash_init(&req->headers_original_case, 0, NULL, NULL, 1);
13431346
req->content = NULL;
13441347
req->content_len = 0;

0 commit comments

Comments
 (0)