Skip to content

Commit 9246b10

Browse files
committed
ext/soap: prevent needless computation of strlen()
1 parent b219c1a commit 9246b10

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

ext/soap/soap.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static ZEND_NORETURN void soap_server_fault(char* code, char* string, char *acto
5555
static void soap_server_fault_ex(sdlFunctionPtr function, zval* fault, soapHeader* hdr);
5656

5757
static sdlParamPtr get_param(sdlFunctionPtr function, const char *param_name, zend_ulong index, int);
58-
static sdlFunctionPtr get_function(sdlPtr sdl, const char *function_name);
58+
static sdlFunctionPtr get_function(sdlPtr sdl, const char *function_name, size_t function_name_length);
5959
static sdlFunctionPtr get_doc_function(sdlPtr sdl, xmlNodePtr params);
6060

6161
static sdlFunctionPtr deserialize_function_call(sdlPtr sdl, xmlDocPtr request, const char* actor, zval *function_name, uint32_t *num_params, zval **parameters, int *version, soapHeader **headers);
@@ -2311,7 +2311,7 @@ static void do_soap_call(zend_execute_data *execute_data,
23112311

23122312
zend_try {
23132313
if (sdl != NULL) {
2314-
fn = get_function(sdl, ZSTR_VAL(function));
2314+
fn = get_function(sdl, ZSTR_VAL(function), ZSTR_LEN(function));
23152315
if (fn != NULL) {
23162316
sdlBindingPtr binding = fn->binding;
23172317
bool one_way = 0;
@@ -3014,7 +3014,8 @@ static sdlFunctionPtr find_function(sdlPtr sdl, xmlNodePtr func, zval* function_
30143014
{
30153015
sdlFunctionPtr function;
30163016

3017-
function = get_function(sdl, (char*)func->name);
3017+
size_t xml_func_name_length = strlen((char*)func->name);
3018+
function = get_function(sdl, (char*)func->name, xml_func_name_length);
30183019
if (function && function->binding && function->binding->bindingType == BINDING_SOAP) {
30193020
sdlSoapBindingFunctionPtr fnb = (sdlSoapBindingFunctionPtr)function->bindingAttributes;
30203021
if (fnb->style == SOAP_DOCUMENT) {
@@ -3032,7 +3033,7 @@ static sdlFunctionPtr find_function(sdlPtr sdl, xmlNodePtr func, zval* function_
30323033
if (function != NULL) {
30333034
ZVAL_STRING(function_name, (char *)function->functionName);
30343035
} else {
3035-
ZVAL_STRING(function_name, (char *)func->name);
3036+
ZVAL_STRINGL(function_name, (char *)func->name, xml_func_name_length);
30363037
}
30373038

30383039
return function;
@@ -4121,18 +4122,17 @@ static sdlParamPtr get_param(sdlFunctionPtr function, const char *param_name, ze
41214122
}
41224123
/* }}} */
41234124

4124-
static sdlFunctionPtr get_function(sdlPtr sdl, const char *function_name) /* {{{ */
4125+
static sdlFunctionPtr get_function(sdlPtr sdl, const char *function_name, size_t function_name_length) /* {{{ */
41254126
{
41264127
sdlFunctionPtr tmp;
41274128

4128-
size_t len = strlen(function_name);
4129-
char *str = estrndup(function_name,len);
4130-
zend_str_tolower(str,len);
4129+
char *str = estrndup(function_name, function_name_length);
4130+
zend_str_tolower(str, function_name_length);
41314131
if (sdl != NULL) {
4132-
if ((tmp = zend_hash_str_find_ptr(&sdl->functions, str, len)) != NULL) {
4132+
if ((tmp = zend_hash_str_find_ptr(&sdl->functions, str, function_name_length)) != NULL) {
41334133
efree(str);
41344134
return tmp;
4135-
} else if (sdl->requests != NULL && (tmp = zend_hash_str_find_ptr(sdl->requests, str, len)) != NULL) {
4135+
} else if (sdl->requests != NULL && (tmp = zend_hash_str_find_ptr(sdl->requests, str, function_name_length)) != NULL) {
41364136
efree(str);
41374137
return tmp;
41384138
}

0 commit comments

Comments
 (0)