Skip to content

Commit ae81549

Browse files
committed
Move SOAP_SERVER_BEGIN_CODE() after zpp
This is still very dubious, because there are lots of other "returns" between the BEGIN and END -- won't that end up not restoring the original state?
1 parent b3ea6ce commit ae81549

File tree

1 file changed

+37
-35
lines changed

1 file changed

+37
-35
lines changed

ext/soap/soap.c

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -957,23 +957,25 @@ PHP_METHOD(SoapServer, setPersistence)
957957
soapServicePtr service;
958958
zend_long value;
959959

960+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &value) == FAILURE) {
961+
RETURN_THROWS();
962+
}
963+
960964
SOAP_SERVER_BEGIN_CODE();
961965

962966
FETCH_THIS_SERVICE(service);
963967

964-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &value) != FAILURE) {
965-
if (service->type == SOAP_CLASS) {
966-
if (value == SOAP_PERSISTENCE_SESSION ||
967-
value == SOAP_PERSISTENCE_REQUEST) {
968-
service->soap_class.persistence = value;
969-
} else {
970-
php_error_docref(NULL, E_WARNING, "Tried to set persistence with bogus value (" ZEND_LONG_FMT ")", value);
971-
return;
972-
}
968+
if (service->type == SOAP_CLASS) {
969+
if (value == SOAP_PERSISTENCE_SESSION ||
970+
value == SOAP_PERSISTENCE_REQUEST) {
971+
service->soap_class.persistence = value;
973972
} else {
974-
php_error_docref(NULL, E_WARNING, "Tried to set persistence when you are using you SOAP SERVER in function mode, no persistence needed");
973+
php_error_docref(NULL, E_WARNING, "Tried to set persistence with bogus value (" ZEND_LONG_FMT ")", value);
975974
return;
976975
}
976+
} else {
977+
php_error_docref(NULL, E_WARNING, "Tried to set persistence when you are using you SOAP SERVER in function mode, no persistence needed");
978+
return;
977979
}
978980

979981
SOAP_SERVER_END_CODE();
@@ -990,14 +992,14 @@ PHP_METHOD(SoapServer, setClass)
990992
int num_args = 0;
991993
zval *argv = NULL;
992994

993-
SOAP_SERVER_BEGIN_CODE();
994-
995-
FETCH_THIS_SERVICE(service);
996-
997995
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S*", &classname, &argv, &num_args) == FAILURE) {
998996
RETURN_THROWS();
999997
}
1000998

999+
SOAP_SERVER_BEGIN_CODE();
1000+
1001+
FETCH_THIS_SERVICE(service);
1002+
10011003
ce = zend_lookup_class(classname);
10021004

10031005
if (ce) {
@@ -1029,14 +1031,14 @@ PHP_METHOD(SoapServer, setObject)
10291031
soapServicePtr service;
10301032
zval *obj;
10311033

1032-
SOAP_SERVER_BEGIN_CODE();
1033-
1034-
FETCH_THIS_SERVICE(service);
1035-
10361034
if (zend_parse_parameters(ZEND_NUM_ARGS(), "o", &obj) == FAILURE) {
10371035
RETURN_THROWS();
10381036
}
10391037

1038+
SOAP_SERVER_BEGIN_CODE();
1039+
1040+
FETCH_THIS_SERVICE(service);
1041+
10401042
service->type = SOAP_OBJECT;
10411043

10421044
ZVAL_OBJ_COPY(&service->soap_object, Z_OBJ_P(obj));
@@ -1052,12 +1054,12 @@ PHP_METHOD(SoapServer, getFunctions)
10521054
soapServicePtr service;
10531055
HashTable *ft = NULL;
10541056

1055-
SOAP_SERVER_BEGIN_CODE();
1056-
10571057
if (zend_parse_parameters_none() == FAILURE) {
10581058
RETURN_THROWS();
10591059
}
10601060

1061+
SOAP_SERVER_BEGIN_CODE();
1062+
10611063
FETCH_THIS_SERVICE(service);
10621064

10631065
array_init(return_value);
@@ -1095,14 +1097,14 @@ PHP_METHOD(SoapServer, addFunction)
10951097
soapServicePtr service;
10961098
zval *function_name, function_copy;
10971099

1098-
SOAP_SERVER_BEGIN_CODE();
1099-
1100-
FETCH_THIS_SERVICE(service);
1101-
11021100
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &function_name) == FAILURE) {
11031101
RETURN_THROWS();
11041102
}
11051103

1104+
SOAP_SERVER_BEGIN_CODE();
1105+
1106+
FETCH_THIS_SERVICE(service);
1107+
11061108
/* TODO: could use zend_is_callable here */
11071109

11081110
if (Z_TYPE_P(function_name) == IS_ARRAY) {
@@ -1214,15 +1216,15 @@ PHP_METHOD(SoapServer, handle)
12141216
int old_features;
12151217
zval tmp_soap;
12161218

1219+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s", &arg, &arg_len) == FAILURE) {
1220+
RETURN_THROWS();
1221+
}
1222+
12171223
SOAP_SERVER_BEGIN_CODE();
12181224

12191225
FETCH_THIS_SERVICE(service);
12201226
SOAP_GLOBAL(soap_version) = service->version;
12211227

1222-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s", &arg, &arg_len) == FAILURE) {
1223-
RETURN_THROWS();
1224-
}
1225-
12261228
if (ZEND_NUM_ARGS() > 0 && ZEND_SIZE_T_INT_OVFL(arg_len)) {
12271229
soap_server_fault("Server", "Input string is too long", NULL, NULL, NULL);
12281230
return;
@@ -1704,17 +1706,17 @@ PHP_METHOD(SoapServer, fault)
17041706
soapServicePtr service;
17051707
xmlCharEncodingHandlerPtr old_encoding;
17061708

1707-
SOAP_SERVER_BEGIN_CODE();
1708-
FETCH_THIS_SERVICE(service);
1709-
old_encoding = SOAP_GLOBAL(encoding);
1710-
SOAP_GLOBAL(encoding) = service->encoding;
1711-
17121709
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|szs",
17131710
&code, &code_len, &string, &string_len, &actor, &actor_len, &details,
17141711
&name, &name_len) == FAILURE) {
17151712
RETURN_THROWS();
17161713
}
17171714

1715+
SOAP_SERVER_BEGIN_CODE();
1716+
FETCH_THIS_SERVICE(service);
1717+
old_encoding = SOAP_GLOBAL(encoding);
1718+
SOAP_GLOBAL(encoding) = service->encoding;
1719+
17181720
soap_server_fault(code, string, actor, details, name);
17191721

17201722
SOAP_GLOBAL(encoding) = old_encoding;
@@ -1729,12 +1731,12 @@ PHP_METHOD(SoapServer, addSoapHeader)
17291731
zval *fault;
17301732
soapHeader **p;
17311733

1732-
SOAP_SERVER_BEGIN_CODE();
1733-
17341734
if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &fault, soap_header_class_entry) == FAILURE) {
17351735
RETURN_THROWS();
17361736
}
17371737

1738+
SOAP_SERVER_BEGIN_CODE();
1739+
17381740
FETCH_THIS_SERVICE(service);
17391741

17401742
if (!service || !service->soap_headers_ptr) {

0 commit comments

Comments
 (0)