Skip to content

Fix #80186: Prevent segfault when iterating FFI obj props #6270

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

adsr
Copy link
Contributor

@adsr adsr commented Oct 4, 2020

@nikic
Copy link
Member

nikic commented Oct 5, 2020

  • zend_vm_execute.h is a generated file. You need to change zend_vm_def.h and then run zend_vm_gen.php.
  • It looks like this issue also exists on PHP-7.4, so we should target that branch instead.
  • Rather than allowing NULL returns, we should do basically what you're doing here, but rather than checking for NULL return, check for an empty array (zend_hash_num_elements(ht) == 0).

@nikic
Copy link
Member

nikic commented Oct 5, 2020

Looking at this code, we probably should also add some fast-path skips for empty arrays in more places, as currently we'll end up allocating a new copy of an empty array, just to free it again right away. But that's a separate issue...

@nikic
Copy link
Member

nikic commented Oct 9, 2020

I've landed a fix in 15443f8 that does the aforementioned check for empty arrays.

@nikic nikic closed this Oct 9, 2020
@adsr
Copy link
Contributor Author

adsr commented Oct 9, 2020

Thanks @nikic Can you add a hacktoberfest-accepted label to this issue?

@nikic
Copy link
Member

nikic commented Oct 9, 2020

Sure, done!

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.

2 participants