Repository navigation
sapi: Follow-up for post-merge comments on GH-23386 - #26006
NattyNarwhal wants to merge 6 commits into
Conversation
Input filters that didn't change the length would result in an empty string.
Unbreak that part.
Note that even before 25c9b84, lsphp leaked: ``` [Tue Dec 1 16:19:57 2026] Script: '-' /Users/calvin/src/php-src/main/SAPI.c(294) : Freeing 0x0000000108c01200 (25 bytes), script=- [Tue Dec 1 16:19:57 2026] Script: '-' /Users/calvin/src/php-src/Zend/zend_ini.c(382) : Freeing 0x0000000108c02000 (56 bytes), script=- [Tue Dec 1 16:19:57 2026] Script: '-' /Users/calvin/src/php-src/Zend/zend_hash.c(191) : Freeing 0x0000000108c03000 (320 bytes), script=- [Tue Dec 1 16:19:57 2026] Script: '-' /Users/calvin/src/php-src/Zend/zend_string.h(449) : Freeing 0x0000000108c07000 (39 bytes), script=- [Tue Dec 1 16:19:57 2026] Script: '-' /Users/calvin/src/php-src/Zend/zend_llist.c(35) : Freeing 0x0000000108c07050 (39 bytes), script=- === Total 5 memory leaks detected === ```
| /* XXX: pretty ugly because input filters aren't zend_string yet. */ | ||
| char *tmp = estrdup(ZSTR_VAL(value)); | ||
| size_t tmp_len = 0; | ||
| size_t tmp_len = ZSTR_LEN(value); |
There was a problem hiding this comment.
I suppose there cannot be a NUL byte in value? In that case, you can optimize the above estrdup call by using estrndup and tmp_len
There was a problem hiding this comment.
I don't think there can be, since all the SAPIs currently call strlen for the length when making zend_strings and prior to the zend_stringification of sapi getenv, it called estrdup anyways.
| return fn_chain[0](&ctx, (fn_activate_user_ini_chain_t*)(fn_chain + 1)); | ||
| int ret = fn_chain[0](&ctx, (fn_activate_user_ini_chain_t*)(fn_chain + 1)); | ||
| if (ctx.doc_root) { | ||
| zend_string_release(ctx.doc_root); |
There was a problem hiding this comment.
I'm not sure what t he lifetime management/ownership rules are here, but it feels icky to release this and not set this to NULL, especially with the NULL check in this branch
There was a problem hiding this comment.
ctx should get deallocated end of scope here. doc_root might not be allocated from lsapi_activate_user_ini_basic_checks, but in that case, we should probably zero-init ctx...
Addressing comments from @ndossche