Skip to content

Prevent unexpected array entry conversion when reading key #16693

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

nielsdos
Copy link
Member

@nielsdos nielsdos commented Nov 3, 2024

When passing an array, the key entry can get converted to a string if it is an object, but this actually modifies the original array entry. The test originally outputted:

array(2) {
  [0]=>
  string(...) => ...
  [1]=>
  string(0) ""
}

i.e. my object in the array got changed into a string
This is unexpected. Use zval_try_get_string() to prevent this behaviour.

Perhaps it's best to only apply this to master?

When passing an array, the key entry can get converted to a string if it
is an object, but this actually modifies the original array entry.
The test originally outputted:

```
array(2) {
  [0]=>
  string(...) => ...
  [1]=>
  string(0) ""
}
```

This is unexpected. Use zval_try_get_string() to prevent this behaviour.
@nielsdos
Copy link
Member Author

nielsdos commented Nov 3, 2024

Also this will fail with a leak probably until my other PRs are merged. EDIT: ah probably not as there are no ASAN jobs on 8.2 apparently

Copy link
Member

@devnexen devnexen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MSTM

@nielsdos nielsdos closed this in ac8d0e5 Nov 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants