Skip to content
Closed
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
5 changes: 5 additions & 0 deletions ext/standard/dl.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ PHPAPI int php_load_extension(const char *filename, int type, int start_now)
return FAILURE;
}
module_entry = get_module();
if (zend_hash_str_exists(&module_registry, module_entry->name, strlen(module_entry->name))) {
DL_UNLOAD(handle);
Comment thread
cmb69 marked this conversation as resolved.
zend_error(E_CORE_WARNING, "Module \"%s\" is already loaded", module_entry->name);
return FAILURE;
Comment thread
cmb69 marked this conversation as resolved.
}
if (module_entry->zend_api != ZEND_MODULE_API_NO) {
php_error_docref(NULL, error_type,
"%s: Unable to initialize module\n"
Expand Down
10 changes: 10 additions & 0 deletions ext/standard/tests/general_functions/gh9589.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--TEST--
dl() segfaults when module is already loaded
--EXTENSIONS--
dl_test

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably sensible to add a comment regarding the usage of dl_test; actually, it doesn't matter which extension we use for the test, but it is mandatory that it is a shared module; this is always given for dl_test.

--FILE--
<?php
dl("dl_test");
?>
--EXPECT--
Warning: Module "dl_test" is already loaded in Unknown on line 0