Skip to content

Commit b7c30c1

Browse files
committed
Return a success value from the startup function, so we can unload immediately
if it fails.
1 parent 84e9ea1 commit b7c30c1

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Zend/zend_extensions.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ int zend_load_extension(char *path)
6363
extension_version_info->required_zend_version,
6464
ZEND_VERSION,
6565
ZEND_EXTENSION_API_NO);
66+
DL_UNLOAD(handle);
6667
return FAILURE;
6768
} else if (extension_version_info->zend_extension_api_no < ZEND_EXTENSION_API_NO) {
6869
/* we may be able to allow for downwards compatability in some harmless cases. */
@@ -73,17 +74,22 @@ int zend_load_extension(char *path)
7374
ZEND_EXTENSION_API_NO,
7475
new_extension->author,
7576
new_extension->URL);
77+
DL_UNLOAD(handle);
7678
return FAILURE;
7779
} else if (ZTS_V!=extension_version_info->thread_safe) {
7880
zend_printf("Cannot load %s - it %s thread safe, whereas Zend %s\n",
7981
new_extension->name,
8082
(extension_version_info->thread_safe?"is":"isn't"),
8183
(ZTS_V?"is":"isn't"));
84+
DL_UNLOAD(handle);
8285
return FAILURE;
8386
}
8487

8588
if (new_extension->startup) {
86-
new_extension->startup(new_extension);
89+
if (new_extension->startup(new_extension)!=SUCCESS) {
90+
DL_UNLOAD(handle);
91+
return FAILURE;
92+
}
8793
}
8894
extension = *new_extension;
8995
extension.handle = handle;

Zend/zend_extensions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ struct _zend_extension {
3737
char *URL;
3838
char *copyright;
3939

40-
void (*startup)(zend_extension *extension);
40+
int (*startup)(zend_extension *extension);
4141
void (*shutdown)(zend_extension *extension);
4242
void (*activate)();
4343
void (*deactivate)();

0 commit comments

Comments
 (0)