Skip to content

fix(webserver): free array values when casting in embedded PHP interpreter - #108

Merged
ngosang merged 1 commit into
amule-org:masterfrom
ngosang:feature/issues4
Jun 11, 2026
Merged

fix(webserver): free array values when casting in embedded PHP interpreter#108
ngosang merged 1 commit into
amule-org:masterfrom
ngosang:feature/issues4

Conversation

@ngosang

@ngosang ngosang commented Jun 11, 2026

Copy link
Copy Markdown
Member

cast_value_str() deleted the PHP_ARRAY_TYPE container but leaked the element var nodes it pointed to, and cast_value_dnum()/cast_value_fnum() dropped an array value without freeing anything. Passing an array to any native builtin (e.g. strlen($arr)) deep-copies it into the call scope and then casts the parameter, leaking that copy.

Factor the correct array teardown out of value_value_free() into a shared free_array_value() helper and use it in all three cast functions.

…reter

cast_value_str() deleted the PHP_ARRAY_TYPE container but leaked the
element var nodes it pointed to, and cast_value_dnum()/cast_value_fnum()
dropped an array value without freeing anything. Passing an array to any
native builtin (e.g. strlen($arr)) deep-copies it into the call scope and
then casts the parameter, leaking that copy.

Factor the correct array teardown out of value_value_free() into a shared
free_array_value() helper and use it in all three cast functions.
@ngosang
ngosang merged commit 97cc2b1 into amule-org:master Jun 11, 2026
10 checks passed
@ngosang
ngosang deleted the feature/issues4 branch June 11, 2026 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant