@@ -810,22 +810,21 @@ static sdlPtr load_wsdl(zval *this_ptr, char *struri)
810810 if (tmpbinding -> bindingType == BINDING_SOAP ) {
811811 sdlSoapBindingPtr soapBinding ;
812812 xmlNodePtr soapBindingNode ;
813- xmlAttrPtr tmp ;
814813
815814 soapBinding = emalloc (sizeof (sdlSoapBinding ));
816815 memset (soapBinding , 0 , sizeof (sdlSoapBinding ));
817816 soapBinding -> style = SOAP_DOCUMENT ;
818817
819818 soapBindingNode = get_node_ex (binding -> children , "binding" , wsdl_soap_namespace );
820819 if (soapBindingNode ) {
821- tmp = get_attribute (soapBindingNode -> properties , "style" );
822- if (tmp && !strncmp ((char * )tmp -> children -> content , "rpc" , sizeof ("rpc" ))) {
820+ xmlAttrPtr styleAttribute = get_attribute (soapBindingNode -> properties , "style" );
821+ if (styleAttribute && !strncmp ((char * )styleAttribute -> children -> content , "rpc" , sizeof ("rpc" ))) {
823822 soapBinding -> style = SOAP_RPC ;
824823 }
825824
826- tmp = get_attribute (soapBindingNode -> properties , "transport" );
827- if (tmp ) {
828- if (strncmp ((char * )tmp -> children -> content , WSDL_HTTP_TRANSPORT , sizeof (WSDL_HTTP_TRANSPORT )) == 0 ) {
825+ xmlAttrPtr transportAttribute = get_attribute (soapBindingNode -> properties , "transport" );
826+ if (transportAttribute ) {
827+ if (strncmp ((char * )transportAttribute -> children -> content , WSDL_HTTP_TRANSPORT , sizeof (WSDL_HTTP_TRANSPORT )) == 0 ) {
829828 soapBinding -> transport = SOAP_TRANSPORT_HTTP ;
830829 } else {
831830 /* try the next binding */
@@ -913,7 +912,6 @@ static sdlPtr load_wsdl(zval *this_ptr, char *struri)
913912 sdlSoapBindingFunctionPtr soapFunctionBinding ;
914913 sdlSoapBindingPtr soapBinding ;
915914 xmlNodePtr soapOperation ;
916- xmlAttrPtr tmp ;
917915
918916 soapFunctionBinding = emalloc (sizeof (sdlSoapBindingFunction ));
919917 memset (soapFunctionBinding , 0 , sizeof (sdlSoapBindingFunction ));
@@ -922,14 +920,14 @@ static sdlPtr load_wsdl(zval *this_ptr, char *struri)
922920
923921 soapOperation = get_node_ex (operation -> children , "operation" , wsdl_soap_namespace );
924922 if (soapOperation ) {
925- tmp = get_attribute (soapOperation -> properties , "soapAction" );
926- if (tmp ) {
927- soapFunctionBinding -> soapAction = estrdup ((char * )tmp -> children -> content );
923+ xmlAttrPtr soapActionAttribute = get_attribute (soapOperation -> properties , "soapAction" );
924+ if (soapActionAttribute ) {
925+ soapFunctionBinding -> soapAction = estrdup ((char * )soapActionAttribute -> children -> content );
928926 }
929927
930- tmp = get_attribute (soapOperation -> properties , "style" );
931- if (tmp ) {
932- if (!strncmp ((char * )tmp -> children -> content , "rpc" , sizeof ("rpc" ))) {
928+ xmlAttrPtr styleAttribute = get_attribute (soapOperation -> properties , "style" );
929+ if (styleAttribute ) {
930+ if (!strncmp ((char * )styleAttribute -> children -> content , "rpc" , sizeof ("rpc" ))) {
933931 soapFunctionBinding -> style = SOAP_RPC ;
934932 } else {
935933 soapFunctionBinding -> style = SOAP_DOCUMENT ;
@@ -1013,11 +1011,11 @@ static sdlPtr load_wsdl(zval *this_ptr, char *struri)
10131011 fault = portTypeOperation -> children ;
10141012 while (fault != NULL ) {
10151013 if (node_is_equal_ex (fault , "fault" , WSDL_NAMESPACE )) {
1016- xmlAttrPtr message , name ;
1014+ xmlAttrPtr message ;
10171015 sdlFaultPtr f ;
10181016
1019- name = get_attribute (fault -> properties , "name" );
1020- if (name == NULL ) {
1017+ xmlAttrPtr faultNameAttribute = get_attribute (fault -> properties , "name" );
1018+ if (faultNameAttribute == NULL ) {
10211019 soap_error1 (E_ERROR , "Parsing WSDL: Missing name for <fault> of '%s'" , op_name -> children -> content );
10221020 }
10231021 message = get_attribute (fault -> properties , "message" );
@@ -1028,54 +1026,53 @@ static sdlPtr load_wsdl(zval *this_ptr, char *struri)
10281026 f = emalloc (sizeof (sdlFault ));
10291027 memset (f , 0 , sizeof (sdlFault ));
10301028
1031- f -> name = estrdup ((char * )name -> children -> content );
1029+ f -> name = estrdup ((char * )faultNameAttribute -> children -> content );
10321030 f -> details = wsdl_message (& ctx , message -> children -> content );
10331031 if (f -> details == NULL || zend_hash_num_elements (f -> details ) > 1 ) {
10341032 soap_error1 (E_ERROR , "Parsing WSDL: The fault message '%s' must have a single part" , message -> children -> content );
10351033 }
10361034
10371035 if (tmpbinding -> bindingType == BINDING_SOAP ) {
1038- xmlNodePtr soap_fault = get_node_with_attribute_ex (operation -> children , "fault" , WSDL_NAMESPACE , "name" , f -> name , NULL );
1039- if (soap_fault != NULL ) {
1040- xmlNodePtr trav = soap_fault -> children ;
1041- while (trav != NULL ) {
1042- if (node_is_equal_ex (trav , "fault" , wsdl_soap_namespace )) {
1043- xmlAttrPtr tmp ;
1044- sdlSoapBindingFunctionFaultPtr binding ;
1045-
1046- binding = f -> bindingAttributes = emalloc (sizeof (sdlSoapBindingFunctionFault ));
1036+ xmlNodePtr soapFault = get_node_with_attribute_ex (operation -> children , "fault" , WSDL_NAMESPACE , "name" , f -> name , NULL );
1037+ if (soapFault != NULL ) {
1038+ xmlNodePtr faultNodes = soapFault -> children ;
1039+ while (faultNodes != NULL ) {
1040+ if (node_is_equal_ex (faultNodes , "fault" , wsdl_soap_namespace )) {
1041+ sdlSoapBindingFunctionFaultPtr faultBinding ;
1042+
1043+ faultBinding = f -> bindingAttributes = emalloc (sizeof (sdlSoapBindingFunctionFault ));
10471044 memset (f -> bindingAttributes , 0 , sizeof (sdlSoapBindingFunctionFault ));
10481045
1049- tmp = get_attribute (trav -> properties , "use" );
1050- if (tmp && !strncmp ((char * )tmp -> children -> content , "encoded" , sizeof ("encoded" ))) {
1051- binding -> use = SOAP_ENCODED ;
1046+ xmlAttrPtr faultUseAttribute = get_attribute (faultNodes -> properties , "use" );
1047+ if (faultUseAttribute && !strncmp ((char * )faultUseAttribute -> children -> content , "encoded" , sizeof ("encoded" ))) {
1048+ faultBinding -> use = SOAP_ENCODED ;
10521049 } else {
1053- binding -> use = SOAP_LITERAL ;
1050+ faultBinding -> use = SOAP_LITERAL ;
10541051 }
10551052
1056- tmp = get_attribute (trav -> properties , "namespace" );
1057- if (tmp ) {
1058- binding -> ns = estrdup ((char * )tmp -> children -> content );
1053+ xmlAttrPtr faultNamespaceAttribute = get_attribute (faultNodes -> properties , "namespace" );
1054+ if (faultNamespaceAttribute ) {
1055+ faultBinding -> ns = estrdup ((char * )faultNamespaceAttribute -> children -> content );
10591056 }
10601057
1061- if (binding -> use == SOAP_ENCODED ) {
1062- tmp = get_attribute (trav -> properties , "encodingStyle" );
1063- if (tmp ) {
1064- if (strncmp ((char * )tmp -> children -> content , SOAP_1_1_ENC_NAMESPACE , sizeof (SOAP_1_1_ENC_NAMESPACE )) == 0 ) {
1065- binding -> encodingStyle = SOAP_ENCODING_1_1 ;
1066- } else if (strncmp ((char * )tmp -> children -> content , SOAP_1_2_ENC_NAMESPACE , sizeof (SOAP_1_2_ENC_NAMESPACE )) == 0 ) {
1067- binding -> encodingStyle = SOAP_ENCODING_1_2 ;
1058+ if (faultBinding -> use == SOAP_ENCODED ) {
1059+ xmlAttrPtr faultEncodingStyleAttribute = get_attribute (faultNodes -> properties , "encodingStyle" );
1060+ if (faultEncodingStyleAttribute ) {
1061+ if (strncmp ((char * )faultEncodingStyleAttribute -> children -> content , SOAP_1_1_ENC_NAMESPACE , sizeof (SOAP_1_1_ENC_NAMESPACE )) == 0 ) {
1062+ faultBinding -> encodingStyle = SOAP_ENCODING_1_1 ;
1063+ } else if (strncmp ((char * )faultEncodingStyleAttribute -> children -> content , SOAP_1_2_ENC_NAMESPACE , sizeof (SOAP_1_2_ENC_NAMESPACE )) == 0 ) {
1064+ faultBinding -> encodingStyle = SOAP_ENCODING_1_2 ;
10681065 } else {
1069- soap_error1 (E_ERROR , "Parsing WSDL: Unknown encodingStyle '%s'" , tmp -> children -> content );
1066+ soap_error1 (E_ERROR , "Parsing WSDL: Unknown encodingStyle '%s'" , faultEncodingStyleAttribute -> children -> content );
10701067 }
10711068 } else {
10721069 soap_error0 (E_ERROR , "Parsing WSDL: Unspecified encodingStyle" );
10731070 }
10741071 }
1075- } else if (is_wsdl_element (trav ) && !node_is_equal (trav ,"documentation" )) {
1076- soap_error1 (E_ERROR , "Parsing WSDL: Unexpected WSDL element <%s>" , SAFE_STR (trav -> name ));
1072+ } else if (is_wsdl_element (faultNodes ) && !node_is_equal (faultNodes ,"documentation" )) {
1073+ soap_error1 (E_ERROR , "Parsing WSDL: Unexpected WSDL element <%s>" , SAFE_STR (faultNodes -> name ));
10771074 }
1078- trav = trav -> next ;
1075+ faultNodes = faultNodes -> next ;
10791076 }
10801077 }
10811078 }
@@ -1093,24 +1090,24 @@ static sdlPtr load_wsdl(zval *this_ptr, char *struri)
10931090 function -> binding = tmpbinding ;
10941091
10951092 {
1096- char * tmp = estrdup (function -> functionName );
1097- size_t len = strlen ( tmp );
1093+ size_t function_name_len = strlen (function -> functionName );
1094+ char * lc_function_name = zend_str_tolower_dup ( function -> functionName , function_name_len );
10981095
1099- zend_str_tolower (tmp , len );
1100- if (zend_hash_str_add_ptr (& ctx .sdl -> functions , tmp , len , function ) == NULL ) {
1096+ if (zend_hash_str_add_ptr (& ctx .sdl -> functions , lc_function_name , function_name_len , function ) == NULL ) {
11011097 zend_hash_next_index_insert_ptr (& ctx .sdl -> functions , function );
11021098 }
1103- efree (tmp );
1099+ efree (lc_function_name );
1100+
11041101 if (function -> requestName != NULL && strcmp (function -> requestName ,function -> functionName ) != 0 ) {
11051102 if (ctx .sdl -> requests == NULL ) {
11061103 ctx .sdl -> requests = emalloc (sizeof (HashTable ));
11071104 zend_hash_init (ctx .sdl -> requests , 0 , NULL , NULL , 0 );
11081105 }
1109- tmp = estrdup ( function -> requestName );
1110- len = strlen (tmp );
1111- zend_str_tolower ( tmp , len );
1112- zend_hash_str_add_ptr (ctx .sdl -> requests , tmp , len , function );
1113- efree (tmp );
1106+
1107+ size_t request_name_len = strlen (function -> requestName );
1108+ char * lc_request_name = zend_str_tolower_dup ( function -> requestName , request_name_len );
1109+ zend_hash_str_add_ptr (ctx .sdl -> requests , lc_request_name , request_name_len , function );
1110+ efree (lc_request_name );
11141111 }
11151112 }
11161113 trav2 = trav2 -> next ;
0 commit comments