From 37123a5474f73f3db51cb726cfb512acca4682c8 Mon Sep 17 00:00:00 2001 From: Martijn Otto Date: Tue, 17 May 2016 15:19:37 +0200 Subject: Fix crash during module finding and fix incomplete types for Value::call() members --- zend/callable.h | 4 ++-- zend/extensionimpl.cpp | 7 +++++-- zend/extensionimpl.h | 2 +- zend/value.cpp | 6 +++--- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/zend/callable.h b/zend/callable.h index 65a971f..b2a7047 100644 --- a/zend/callable.h +++ b/zend/callable.h @@ -113,9 +113,9 @@ protected: /** * Required number of arguments - * @var integer + * @var unsigned integer */ - int _required = 0; + unsigned int _required = 0; /** * Total number of arguments diff --git a/zend/extensionimpl.cpp b/zend/extensionimpl.cpp index 5261b0d..bc29cf1 100644 --- a/zend/extensionimpl.cpp +++ b/zend/extensionimpl.cpp @@ -63,8 +63,11 @@ static std::map number2extension; * * @param zend_module_entry */ -static int match_module(zend_module_entry *entry) +static int match_module(zval *value TSRMLS_DC) { + // retrieve the module entry from the zval + auto *entry = (zend_module_entry*)Z_PTR_P(value); + // check if there is an extension with this name auto iter = name2extension.find(entry->name); if (iter == name2extension.end()) return ZEND_HASH_APPLY_KEEP; @@ -89,7 +92,7 @@ static ExtensionImpl *find(int number TSRMLS_DC) if (iter != number2extension.end()) return iter->second; // no, not yet, loop through all modules - zend_hash_apply(&module_registry, (apply_func_t)match_module TSRMLS_CC); + zend_hash_apply(&module_registry, match_module TSRMLS_CC); // find again iter = number2extension.find(number); diff --git a/zend/extensionimpl.h b/zend/extensionimpl.h index b933624..aef4802 100644 --- a/zend/extensionimpl.h +++ b/zend/extensionimpl.h @@ -103,7 +103,7 @@ public: private: /** - * Initialize the namespace after it was registered + * Initialize the extension after it was registered * @param module_number * @param tsrm_ls * @return bool diff --git a/zend/value.cpp b/zend/value.cpp index 40308f4..547ff85 100644 --- a/zend/value.cpp +++ b/zend/value.cpp @@ -893,7 +893,7 @@ Value Value::exec(int argc, Value *argv) const zval params[argc]; // convert all the values - for(unsigned i=0; i < argc; i++) { params[i] = *argv[i]._val; } + for(int i = 0; i < argc; i++) { params[i] = *argv[i]._val; } // call helper function return do_exec(nullptr, _val, argc, params); @@ -915,7 +915,7 @@ Value Value::exec(const char *name, int argc, Value *argv) const zval params[argc]; // convert all the values - for(unsigned i=0; i < argc; i++) { params[i] = *argv[i]._val; } + for(int i = 0; i < argc; i++) { params[i] = *argv[i]._val; } // call helper function return do_exec(_val, method._val, argc, params); @@ -937,7 +937,7 @@ Value Value::exec(const char *name, int argc, Value *argv) zval params[argc]; // convert all the values - for(unsigned i=0; i < argc; i++) { params[i] = *argv[i]._val; } + for(int i = 0; i < argc; i++) { params[i] = *argv[i]._val; } // call helper function return do_exec(_val, method._val, argc, params); -- cgit v1.2.3