Skip to content

Commit b63df3c

Browse files
authored
Stop copying zend_module_entry (#8551)
I did some historical digging and could not figure out why a copy is made. Additionally, the copy was not using the `.size` member, so it was probably wrong, but it's been that way for quite some time.
1 parent cf971a1 commit b63df3c

File tree

3 files changed

+2
-4
lines changed

3 files changed

+2
-4
lines changed

UPGRADING.INTERNALS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ PHP 8.2 INTERNALS UPGRADE NOTES
2020
* php_stristr() no longer lowercases the haystack and needle as a side effect.
2121
Call zend_str_tolower() yourself if necessary. You no longer need to copy
2222
the haystack and needle before passing them to php_stristr().
23+
* zend_register_module_ex() no longer copies the module entry.
2324

2425
========================
2526
2. Build system changes

Zend/zend.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -841,9 +841,7 @@ static void php_scanner_globals_ctor(zend_php_scanner_globals *scanner_globals_p
841841
static void module_destructor_zval(zval *zv) /* {{{ */
842842
{
843843
zend_module_entry *module = (zend_module_entry*)Z_PTR_P(zv);
844-
845844
module_destructor(module);
846-
free(module);
847845
}
848846
/* }}} */
849847

Zend/zend_API.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2378,7 +2378,7 @@ ZEND_API zend_module_entry* zend_register_module_ex(zend_module_entry *module) /
23782378
zend_str_tolower_copy(ZSTR_VAL(lcname), module->name, name_len);
23792379

23802380
lcname = zend_new_interned_string(lcname);
2381-
if ((module_ptr = zend_hash_add_mem(&module_registry, lcname, module, sizeof(zend_module_entry))) == NULL) {
2381+
if ((module_ptr = zend_hash_add_ptr(&module_registry, lcname, module)) == NULL) {
23822382
zend_error(E_CORE_WARNING, "Module \"%s\" is already loaded", module->name);
23832383
zend_string_release(lcname);
23842384
return NULL;
@@ -3061,7 +3061,6 @@ ZEND_API void zend_post_deactivate_modules(void) /* {{{ */
30613061
break;
30623062
}
30633063
module_destructor(module);
3064-
free(module);
30653064
zend_string_release_ex(key, 0);
30663065
} ZEND_HASH_MAP_FOREACH_END_DEL();
30673066
} else {

0 commit comments

Comments
 (0)