Skip to content
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

Avoid unnecessary string refcounting in ext/mbstring #17892

Merged
merged 1 commit into from
Feb 22, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions ext/mbstring/mbstring.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,8 @@ static zend_result php_mb_parse_encoding_array(HashTable *target_hash, const mbf
size_t n = 0;
zval *hash_entry;
ZEND_HASH_FOREACH_VAL(target_hash, hash_entry) {
zend_string *encoding_str = zval_try_get_string(hash_entry);
zend_string *tmp_encoding_str;
zend_string *encoding_str = zval_try_get_tmp_string(hash_entry, &tmp_encoding_str);
if (UNEXPECTED(!encoding_str)) {
efree(ZEND_VOIDP(list));
return FAILURE;
Expand All @@ -415,12 +416,12 @@ static zend_result php_mb_parse_encoding_array(HashTable *target_hash, const mbf
n++;
} else {
zend_argument_value_error(arg_num, "contains invalid encoding \"%s\"", ZSTR_VAL(encoding_str));
zend_string_release(encoding_str);
zend_tmp_string_release(tmp_encoding_str);
efree(ZEND_VOIDP(list));
return FAILURE;
}
}
zend_string_release(encoding_str);
zend_tmp_string_release(tmp_encoding_str);
} ZEND_HASH_FOREACH_END();
*return_list = list;
*return_size = n;
Expand Down
Loading