Skip to content

Commit cde2e35

Browse files
committed
Merge branch 'PHP-7.3'
* PHP-7.3: Fix #77297: SodiumException segfaults on PHP 7.3
2 parents 9216f5b + e0e08d3 commit cde2e35

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

ext/sodium/libsodium.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,8 @@ static void sodium_remove_param_values_from_backtrace(zend_object *obj) {
387387
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(trace), frame) {
388388
if (Z_TYPE_P(frame) == IS_ARRAY) {
389389
zval *args = zend_hash_str_find(Z_ARRVAL_P(frame), "args", sizeof("args")-1);
390-
if (args && Z_TYPE_P(frame) == IS_ARRAY) {
391-
zend_hash_clean(Z_ARRVAL_P(args));
392-
}
390+
zval_ptr_dtor(args);
391+
ZVAL_EMPTY_ARRAY(args);
393392
}
394393
} ZEND_HASH_FOREACH_END();
395394
}

ext/sodium/tests/utils.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,17 @@ if (defined('SODIUM_BASE64_VARIANT_ORIGINAL')) {
9393
var_dump('base64("O") case passed');
9494
var_dump('abcd');
9595
}
96+
97+
function sodium_foo()
98+
{
99+
throw new SodiumException('test');
100+
}
101+
102+
try {
103+
sodium_foo();
104+
} catch (SodiumException $ex) {
105+
var_dump($ex->getMessage());
106+
}
96107

97108
?>
98109
--EXPECT--
@@ -114,3 +125,4 @@ string(25) "base64("O1R") case passed"
114125
string(24) "base64("O1") case passed"
115126
string(23) "base64("O") case passed"
116127
string(4) "abcd"
128+
string(4) "test"

0 commit comments

Comments
 (0)