-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix segfault on PHP 7.3 #3708
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
Fix segfault on PHP 7.3 #3708
Conversation
ext/sodium/libsodium.c
Outdated
@@ -387,7 +387,8 @@ static void sodium_remove_param_values_from_backtrace(zend_object *obj) { | |||
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(trace), frame) { | |||
if (Z_TYPE_P(frame) == IS_ARRAY) { | |||
zval *args = zend_hash_str_find(Z_ARRVAL_P(frame), "args", sizeof("args")-1); | |||
if (args && Z_TYPE_P(frame) == IS_ARRAY) { | |||
if (args != NULL && Z_TYPE_P(args) == IS_ARRAY && | |||
Z_REFCOUNTED_P(args) && Z_REFCOUNT_P(args) == 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the intention here is to hide arguments, this check would kinda defeat the point in the cases where it triggers. As an alternative, I'd suggest doing something like
zval *args = zend_hash_str_find(Z_ARRVAL_P(frame), "args", sizeof("args")-1);
zval_ptr_dtor(args);
ZVAL_EMPTY_ARRAY(args);
in order to overwrite with an empty array, without corrupting the original one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @jedisct1
Could you please also add a test file, to avoid regressing this in the future? |
Yep! :) |
I have no idea what's going on with the Windows build here, but it seems wholly unrelated to the libsodium change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AppVeyor failure is intermittent.
Thanks! Applied as e0e08d3. |
https://bugs.php.net/bug.php?id=77297
jedisct1/libsodium-php@736b7d1