From 6ac580c95f354e997d96dfb49d79b2bcb003d044 Mon Sep 17 00:00:00 2001 From: arshidkv12 Date: Mon, 15 Jun 2026 22:06:47 +0530 Subject: [PATCH] Zend: avoid strlen() in zend_get_module_version() --- Zend/zend_API.c | 11 ++++++++--- Zend/zend_API.h | 1 + ext/standard/info.c | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 65834adbafff..40bd1096d09f 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -4411,12 +4411,17 @@ ZEND_API void zend_get_callable_zval_from_fcc(const zend_fcall_info_cache *fcc, } } -ZEND_API const char *zend_get_module_version(const char *module_name) /* {{{ */ +ZEND_API const char *zend_get_module_version_ex(const char *module_name, size_t module_name_len) { - size_t name_len = strlen(module_name); - zend_module_entry *module = zend_hash_str_find_ptr_lc(&module_registry, module_name, name_len); + zend_module_entry *module = zend_hash_str_find_ptr_lc(&module_registry, module_name, module_name_len); return module ? module->version : NULL; } + +ZEND_API const char *zend_get_module_version(const char *module_name) /* {{{ */ +{ + size_t name_len = strlen(module_name); + return zend_get_module_version_ex(module_name, name_len); +} /* }}} */ static zend_always_inline bool is_persistent_class(const zend_class_entry *ce) { diff --git a/Zend/zend_API.h b/Zend/zend_API.h index 2487c8b632f2..7aa5346a4f83 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -421,6 +421,7 @@ ZEND_API bool zend_is_callable_at_frame( ZEND_API bool zend_is_callable_ex(const zval *callable, zend_object *object, uint32_t check_flags, zend_string **callable_name, zend_fcall_info_cache *fcc, char **error); ZEND_API bool zend_is_callable(const zval *callable, uint32_t check_flags, zend_string **callable_name); ZEND_API const char *zend_get_module_version(const char *module_name); +ZEND_API const char *zend_get_module_version_ex(const char *module_name, size_t module_name_name_len); ZEND_API zend_result zend_get_module_started(const char *module_name); ZEND_API zend_property_info *zend_declare_typed_property(zend_class_entry *ce, zend_string *name, zval *property, int access_type, zend_string *doc_comment, zend_type type); diff --git a/ext/standard/info.c b/ext/standard/info.c index dcb01bc08220..c792666b5261 100644 --- a/ext/standard/info.c +++ b/ext/standard/info.c @@ -1308,7 +1308,7 @@ PHP_FUNCTION(phpversion) RETURN_STRING(PHP_VERSION); } else { const char *version; - version = zend_get_module_version(ext_name); + version = zend_get_module_version_ex(ext_name, ext_name_len); if (version == NULL) { RETURN_FALSE; }