diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 776659ca11934..c5273568f7f1e 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -3271,7 +3271,7 @@ ZEND_API void zend_post_deactivate_modules(void) /* {{{ */ /* return the next free module number */ ZEND_API int zend_next_free_module(void) /* {{{ */ { - return zend_hash_num_elements(&module_registry) + 1; + return zend_hash_num_elements(&module_registry); } /* }}} */ diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index ec1134cd7f2b3..5ca335170a216 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -59,7 +59,13 @@ zend_module_entry zend_builtin_module = { /* {{{ */ zend_result zend_startup_builtin_functions(void) /* {{{ */ { - return (EG(current_module) = zend_register_module_ex(&zend_builtin_module, MODULE_PERSISTENT)) == NULL ? FAILURE : SUCCESS; + zend_module_entry *module; + EG(current_module) = module = zend_register_module_ex(&zend_builtin_module, MODULE_PERSISTENT); + if (UNEXPECTED(module == NULL)) { + return FAILURE; + } + ZEND_ASSERT(module->module_number == 0); + return SUCCESS; } /* }}} */ diff --git a/sapi/cli/tests/025.phpt b/sapi/cli/tests/025.phpt new file mode 100644 index 0000000000000..f0dcb10753210 --- /dev/null +++ b/sapi/cli/tests/025.phpt @@ -0,0 +1,19 @@ +--TEST-- +CLI php -i extension_dir +--SKIPIF-- + +--FILE-- + ")); + +?> +--EXPECT-- +bool(true)