Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions UPGRADING.INTERNALS
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ PHP 8.6 INTERNALS UPGRADE NOTES
printf family.
. The zval_dtor() alias of zval_ptr_dtor_nogc() has been removed.
Call zval_ptr_dtor_nogc() directly instead.
. The internal zend_copy_parameters_array() function is no longer exposed.

========================
2. Build system changes
Expand Down
22 changes: 0 additions & 22 deletions Zend/zend_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,28 +76,6 @@ ZEND_API zend_result zend_get_parameters_array_ex(uint32_t param_count, zval *ar
}
/* }}} */

ZEND_API zend_result zend_copy_parameters_array(uint32_t param_count, zval *argument_array) /* {{{ */
{
zval *param_ptr;
uint32_t arg_count;

param_ptr = ZEND_CALL_ARG(EG(current_execute_data), 1);
arg_count = ZEND_CALL_NUM_ARGS(EG(current_execute_data));

if (param_count>arg_count) {
return FAILURE;
}

while (param_count-->0) {
Z_TRY_ADDREF_P(param_ptr);
zend_hash_next_index_insert_new(Z_ARRVAL_P(argument_array), param_ptr);
param_ptr++;
}

return SUCCESS;
}
/* }}} */

ZEND_API ZEND_COLD void zend_wrong_param_count(void) /* {{{ */
{
const char *space;
Expand Down
3 changes: 0 additions & 3 deletions Zend/zend_API.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,6 @@ ZEND_API void zend_set_dl_use_deepbind(bool use_deepbind);

ZEND_API zend_result zend_get_parameters_array_ex(uint32_t param_count, zval *argument_array);

/* internal function to efficiently copy parameters when executing __call() */
ZEND_API zend_result zend_copy_parameters_array(uint32_t param_count, zval *argument_array);

#define zend_get_parameters_array(ht, param_count, argument_array) \
zend_get_parameters_array_ex(param_count, argument_array)
#define zend_parse_parameters_none() \
Expand Down
17 changes: 15 additions & 2 deletions Zend/zend_closures.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,19 @@ ZEND_METHOD(Closure, bindTo)
do_closure_bind(return_value, ZEND_THIS, newthis, scope_obj, scope_str);
}

static void zend_copy_parameters_array(const uint32_t param_count, HashTable *argument_array) /* {{{ */
{
zval *param_ptr = ZEND_CALL_ARG(EG(current_execute_data), 1);

ZEND_ASSERT(param_count <= ZEND_CALL_NUM_ARGS(EG(current_execute_data)));

for (uint32_t i = 0; i < param_count; i++) {
Z_TRY_ADDREF_P(param_ptr);
zend_hash_next_index_insert_new(argument_array, param_ptr);
param_ptr++;
}
}

static ZEND_NAMED_FUNCTION(zend_closure_call_magic) /* {{{ */ {
zend_fcall_info fci;
zend_fcall_info_cache fcc;
Expand All @@ -310,14 +323,14 @@ static ZEND_NAMED_FUNCTION(zend_closure_call_magic) /* {{{ */ {
array_init_size(&fci.params[1], ZEND_NUM_ARGS() + zend_hash_num_elements(EX(extra_named_params)));
/* Avoid conversion from packed to mixed later. */
zend_hash_real_init_mixed(Z_ARRVAL(fci.params[1]));
zend_copy_parameters_array(ZEND_NUM_ARGS(), &fci.params[1]);
zend_copy_parameters_array(ZEND_NUM_ARGS(), Z_ARRVAL(fci.params[1]));
ZEND_HASH_MAP_FOREACH_STR_KEY_VAL(EX(extra_named_params), name, named_param_zval) {
Z_TRY_ADDREF_P(named_param_zval);
zend_hash_add_new(Z_ARRVAL(fci.params[1]), name, named_param_zval);
} ZEND_HASH_FOREACH_END();
} else if (ZEND_NUM_ARGS()) {
array_init_size(&fci.params[1], ZEND_NUM_ARGS());
zend_copy_parameters_array(ZEND_NUM_ARGS(), &fci.params[1]);
zend_copy_parameters_array(ZEND_NUM_ARGS(), Z_ARRVAL(fci.params[1]));
} else {
ZVAL_EMPTY_ARRAY(&fci.params[1]);
}
Expand Down
57 changes: 26 additions & 31 deletions ext/phar/phar.c
Original file line number Diff line number Diff line change
Expand Up @@ -2034,45 +2034,40 @@ zend_result phar_detect_phar_fname_ext(const char *filename, size_t filename_len
}
}

// TODO Use some sort of loop here instead of a goto
pos = memchr(filename + 1, '.', filename_len);
next_extension:
if (!pos) {
return FAILURE;
}

while (pos != filename && (*(pos - 1) == '/' || *(pos - 1) == '\0')) {
pos = memchr(pos + 1, '.', filename_len - (pos - filename) - 1);
if (!pos) {
return FAILURE;
while (pos) {
while (pos != filename && (*(pos - 1) == '/' || *(pos - 1) == '\0')) {
pos = memchr(pos + 1, '.', filename_len - (pos - filename) - 1);
if (!pos) {
return FAILURE;
}
}
}

slash = memchr(pos, '/', filename_len - (pos - filename));
slash = memchr(pos, '/', filename_len - (pos - filename));

if (!slash) {
/* this is a url like "phar://blah.phar" with no directory */
*ext_str = pos;
*ext_len = strlen(pos);
if (!slash) {
/* this is a url like "phar://blah.phar" with no directory */
*ext_str = pos;
*ext_len = strlen(pos);

/* file extension must contain "phar" */
return phar_check_str(filename, *ext_str, *ext_len, executable, for_create);
}
/* file extension must contain "phar" */
return phar_check_str(filename, *ext_str, *ext_len, executable, for_create);
}

/* we've found an extension that ends at a directory separator */
*ext_str = pos;
*ext_len = slash - pos;
/* we've found an extension that ends at a directory separator */
*ext_str = pos;
*ext_len = slash - pos;

if (phar_check_str(filename, *ext_str, *ext_len, executable, for_create) == SUCCESS) {
return SUCCESS;
}
if (phar_check_str(filename, *ext_str, *ext_len, executable, for_create) == SUCCESS) {
return SUCCESS;
}

/* look for more extensions */
pos = strchr(pos + 1, '.');
if (pos) {
*ext_str = NULL;
*ext_len = 0;
goto next_extension;
/* look for more extensions */
pos = strchr(pos + 1, '.');
if (pos) {
*ext_str = NULL;
*ext_len = 0;
}
}

return FAILURE;
Expand Down
6 changes: 0 additions & 6 deletions ext/phar/tar.c
Original file line number Diff line number Diff line change
Expand Up @@ -1242,12 +1242,6 @@ ZEND_ATTRIBUTE_NONNULL_ARGS(1, 4) void phar_tar_flush(phar_archive_data *phar, z
php_stream_close(oldfile);
}

/* on error in the hash iterator above, error is set */
if (*error) {
php_stream_close(newfile);
return;
}

if (phar->fp && pass.free_fp) {
php_stream_close(phar->fp);
}
Expand Down
2 changes: 2 additions & 0 deletions ext/zip/php_zip.c
Original file line number Diff line number Diff line change
Expand Up @@ -3045,6 +3045,7 @@ PHP_METHOD(ZipArchive, registerProgressCallback)

/* register */
if (zip_register_progress_callback_with_state(intern, rate, php_zip_progress_callback, php_zip_progress_callback_free, obj)) {
zend_release_fcall_info_cache(&fcc);
RETURN_FALSE;
}
zend_fcc_dup(&obj->progress_callback, &fcc);
Expand Down Expand Up @@ -3104,6 +3105,7 @@ PHP_METHOD(ZipArchive, registerCancelCallback)

/* register */
if (zip_register_cancel_callback_with_state(intern, php_zip_cancel_callback, php_zip_cancel_callback_free, obj)) {
zend_release_fcall_info_cache(&fcc);
RETURN_FALSE;
}
zend_fcc_dup(&obj->cancel_callback, &fcc);
Expand Down