Skip to content

Commit 6cb3b94

Browse files
committed
Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5: Improve fix for bug 67741 Added type checks Added type checks
2 parents f353162 + 304fb7a commit 6cb3b94

File tree

4 files changed

+76
-46
lines changed

4 files changed

+76
-46
lines changed

ext/soap/php_encoding.c

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -402,12 +402,15 @@ static xmlNodePtr master_to_xml_int(encodePtr encode, zval *data, int style, xml
402402
encodePtr enc = NULL;
403403
HashTable *ht = Z_OBJPROP_P(data);
404404

405-
if (zend_hash_find(ht, "enc_type", sizeof("enc_type"), (void **)&ztype) == FAILURE) {
405+
if (zend_hash_find(ht, "enc_type", sizeof("enc_type"), (void **)&ztype) == FAILURE ||
406+
Z_TYPE_PP(ztype) != IS_LONG) {
406407
soap_error0(E_ERROR, "Encoding: SoapVar has no 'enc_type' property");
407408
}
408409

409-
if (zend_hash_find(ht, "enc_stype", sizeof("enc_stype"), (void **)&zstype) == SUCCESS) {
410-
if (zend_hash_find(ht, "enc_ns", sizeof("enc_ns"), (void **)&zns) == SUCCESS) {
410+
if (zend_hash_find(ht, "enc_stype", sizeof("enc_stype"), (void **)&zstype) == SUCCESS &&
411+
Z_TYPE_PP(zstype) == IS_STRING) {
412+
if (zend_hash_find(ht, "enc_ns", sizeof("enc_ns"), (void **)&zns) == SUCCESS &&
413+
Z_TYPE_PP(zns) == IS_STRING) {
411414
enc = get_encoder(SOAP_GLOBAL(sdl), Z_STRVAL_PP(zns), Z_STRVAL_PP(zstype));
412415
} else {
413416
zns = NULL;
@@ -443,19 +446,23 @@ static xmlNodePtr master_to_xml_int(encodePtr encode, zval *data, int style, xml
443446
}
444447

445448
if (style == SOAP_ENCODED || (SOAP_GLOBAL(sdl) && encode != enc)) {
446-
if (zend_hash_find(ht, "enc_stype", sizeof("enc_stype"), (void **)&zstype) == SUCCESS) {
447-
if (zend_hash_find(ht, "enc_ns", sizeof("enc_ns"), (void **)&zns) == SUCCESS) {
449+
if (zend_hash_find(ht, "enc_stype", sizeof("enc_stype"), (void **)&zstype) == SUCCESS &&
450+
Z_TYPE_PP(zstype) == IS_STRING) {
451+
if (zend_hash_find(ht, "enc_ns", sizeof("enc_ns"), (void **)&zns) == SUCCESS &&
452+
Z_TYPE_PP(zns) == IS_STRING) {
448453
set_ns_and_type_ex(node, Z_STRVAL_PP(zns), Z_STRVAL_PP(zstype));
449454
} else {
450455
set_ns_and_type_ex(node, NULL, Z_STRVAL_PP(zstype));
451456
}
452457
}
453458
}
454459

455-
if (zend_hash_find(ht, "enc_name", sizeof("enc_name"), (void **)&zname) == SUCCESS) {
460+
if (zend_hash_find(ht, "enc_name", sizeof("enc_name"), (void **)&zname) == SUCCESS &&
461+
Z_TYPE_PP(zname) == IS_STRING) {
456462
xmlNodeSetName(node, BAD_CAST(Z_STRVAL_PP(zname)));
457463
}
458-
if (zend_hash_find(ht, "enc_namens", sizeof("enc_namens"), (void **)&znamens) == SUCCESS) {
464+
if (zend_hash_find(ht, "enc_namens", sizeof("enc_namens"), (void **)&znamens) == SUCCESS &&
465+
Z_TYPE_PP(zname) == IS_STRING) {
459466
xmlNsPtr nsp = encode_add_ns(node, Z_STRVAL_PP(znamens));
460467
xmlSetNs(node, nsp);
461468
}
@@ -3638,18 +3645,21 @@ static encodePtr get_array_type(xmlNodePtr node, zval *array, smart_str *type TS
36383645
Z_OBJCE_PP(tmp) == soap_var_class_entry) {
36393646
zval **ztype;
36403647

3641-
if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_type", sizeof("enc_type"), (void **)&ztype) == FAILURE) {
3648+
if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_type", sizeof("enc_type"), (void **)&ztype) == FAILURE ||
3649+
Z_TYPE_PP(ztype) != IS_LONG) {
36423650
soap_error0(E_ERROR, "Encoding: SoapVar has no 'enc_type' property");
36433651
}
36443652
cur_type = Z_LVAL_PP(ztype);
36453653

3646-
if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_stype", sizeof("enc_stype"), (void **)&ztype) == SUCCESS) {
3654+
if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_stype", sizeof("enc_stype"), (void **)&ztype) == SUCCESS &&
3655+
Z_TYPE_PP(ztype) == IS_STRING) {
36473656
cur_stype = Z_STRVAL_PP(ztype);
36483657
} else {
36493658
cur_stype = NULL;
36503659
}
36513660

3652-
if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_ns", sizeof("enc_ns"), (void **)&ztype) == SUCCESS) {
3661+
if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_ns", sizeof("enc_ns"), (void **)&ztype) == SUCCESS &&
3662+
Z_TYPE_PP(ztype) == IS_STRING) {
36533663
cur_ns = Z_STRVAL_PP(ztype);
36543664
} else {
36553665
cur_ns = NULL;

ext/soap/php_http.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,16 @@ int proxy_authentication(zval* this_ptr, smart_str* soap_headers TSRMLS_DC)
3636
{
3737
zval **login, **password;
3838

39-
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_proxy_login", sizeof("_proxy_login"), (void **)&login) == SUCCESS) {
39+
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_proxy_login", sizeof("_proxy_login"), (void **)&login) == SUCCESS &&
40+
Z_TYPE_PP(login) == IS_STRING) {
4041
unsigned char* buf;
4142
int len;
4243
smart_str auth = {0};
4344

4445
smart_str_appendl(&auth, Z_STRVAL_PP(login), Z_STRLEN_PP(login));
4546
smart_str_appendc(&auth, ':');
46-
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_proxy_password", sizeof("_proxy_password"), (void **)&password) == SUCCESS) {
47+
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_proxy_password", sizeof("_proxy_password"), (void **)&password) == SUCCESS &&
48+
Z_TYPE_PP(password) == IS_STRING) {
4749
smart_str_appendl(&auth, Z_STRVAL_PP(password), Z_STRLEN_PP(password));
4850
}
4951
smart_str_0(&auth);
@@ -64,14 +66,16 @@ int basic_authentication(zval* this_ptr, smart_str* soap_headers TSRMLS_DC)
6466
zval **login, **password;
6567

6668
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_login", sizeof("_login"), (void **)&login) == SUCCESS &&
67-
!zend_hash_exists(Z_OBJPROP_P(this_ptr), "_digest", sizeof("_digest"))) {
69+
Z_TYPE_PP(login) == IS_STRING &&
70+
!zend_hash_exists(Z_OBJPROP_P(this_ptr), "_digest", sizeof("_digest"))) {
6871
unsigned char* buf;
6972
int len;
7073
smart_str auth = {0};
7174

7275
smart_str_appendl(&auth, Z_STRVAL_PP(login), Z_STRLEN_PP(login));
7376
smart_str_appendc(&auth, ':');
74-
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_password", sizeof("_password"), (void **)&password) == SUCCESS) {
77+
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_password", sizeof("_password"), (void **)&password) == SUCCESS &&
78+
Z_TYPE_PP(password) == IS_STRING) {
7579
smart_str_appendl(&auth, Z_STRVAL_PP(password), Z_STRLEN_PP(password));
7680
}
7781
smart_str_0(&auth);
@@ -571,6 +575,7 @@ int make_http_soap_request(zval *this_ptr,
571575
}
572576
if (!http_1_1 ||
573577
(zend_hash_find(Z_OBJPROP_P(this_ptr), "_keep_alive", sizeof("_keep_alive"), (void **)&tmp) == SUCCESS &&
578+
(Z_TYPE_PP(tmp) == IS_BOOL || Z_TYPE_PP(tmp) == IS_LONG) &&
574579
Z_LVAL_PP(tmp) == 0)) {
575580
smart_str_append_const(&soap_headers, "\r\n"
576581
"Connection: close\r\n");
@@ -804,7 +809,8 @@ int make_http_soap_request(zval *this_ptr,
804809
}
805810

806811
/* Send cookies along with request */
807-
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS) {
812+
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS &&
813+
Z_TYPE_PP(cookies) == IS_ARRAY) {
808814
zval **data;
809815
char *key;
810816
uint key_len;
@@ -848,7 +854,7 @@ int make_http_soap_request(zval *this_ptr,
848854
smart_str_append_const(&soap_headers, "\r\n");
849855
smart_str_0(&soap_headers);
850856
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
851-
Z_LVAL_PP(trace) > 0) {
857+
(Z_TYPE_PP(trace) == IS_BOOL || Z_TYPE_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
852858
add_property_stringl(this_ptr, "__last_request_headers", soap_headers.c, soap_headers.len, 1);
853859
}
854860
smart_str_appendl(&soap_headers, request, request_size);
@@ -893,7 +899,7 @@ int make_http_soap_request(zval *this_ptr,
893899
}
894900

895901
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
896-
Z_LVAL_PP(trace) > 0) {
902+
(Z_TYPE_PP(trace) == IS_BOOL || Z_TYPE_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
897903
add_property_stringl(this_ptr, "__last_response_headers", http_headers, http_header_size, 1);
898904
}
899905

@@ -942,7 +948,8 @@ int make_http_soap_request(zval *this_ptr,
942948
char *eqpos, *sempos;
943949
zval **cookies;
944950

945-
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE) {
951+
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE ||
952+
Z_TYPE_PP(cookies) != IS_ARRAY) {
946953
zval *tmp_cookies;
947954
MAKE_STD_ZVAL(tmp_cookies);
948955
array_init(tmp_cookies);

ext/soap/soap.c

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2563,7 +2563,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
25632563
}
25642564

25652565
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
2566-
Z_TYPE_PP(trace) == IS_LONG && Z_LVAL_PP(trace) > 0) {
2566+
(Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
25672567
add_property_stringl(this_ptr, "__last_request", buf, buf_size, 1);
25682568
}
25692569

@@ -2598,7 +2598,7 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
25982598
}
25992599
ret = FALSE;
26002600
} else if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
2601-
Z_TYPE_PP(trace) == IS_LONG && Z_LVAL_PP(trace) > 0) {
2601+
(Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
26022602
add_property_stringl(this_ptr, "__last_response", Z_STRVAL_P(response), Z_STRLEN_P(response), 1);
26032603
}
26042604
zval_ptr_dtor(&params[4]);
@@ -2642,13 +2642,13 @@ static void do_soap_call(zval* this_ptr,
26422642

26432643
SOAP_CLIENT_BEGIN_CODE();
26442644

2645-
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS
2646-
&& Z_LVAL_PP(trace) > 0) {
2645+
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS &&
2646+
(Z_LVAL_PP(trace) == IS_BOOL || Z_LVAL_PP(trace) == IS_LONG) && Z_LVAL_PP(trace) != 0) {
26472647
zend_hash_del(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"));
26482648
zend_hash_del(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"));
26492649
}
2650-
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_soap_version", sizeof("_soap_version"), (void **) &tmp) == SUCCESS
2651-
&& Z_LVAL_PP(tmp) == SOAP_1_2) {
2650+
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_soap_version", sizeof("_soap_version"), (void **) &tmp) == SUCCESS &&
2651+
Z_TYPE_PP(tmp) == IS_LONG && Z_LVAL_PP(tmp) == SOAP_1_2) {
26522652
soap_version = SOAP_1_2;
26532653
} else {
26542654
soap_version = SOAP_1_1;
@@ -2745,7 +2745,7 @@ static void do_soap_call(zval* this_ptr,
27452745
zval **uri;
27462746
smart_str action = {0};
27472747

2748-
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri"), (void *)&uri) == FAILURE) {
2748+
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri"), (void *)&uri) == FAILURE || Z_TYPE_PP(uri) != IS_STRING) {
27492749
add_soap_fault(this_ptr, "Client", "Error finding \"uri\" property", NULL, NULL TSRMLS_CC);
27502750
} else if (location == NULL) {
27512751
add_soap_fault(this_ptr, "Client", "Error could not find \"location\" property", NULL, NULL TSRMLS_CC);
@@ -3024,7 +3024,8 @@ PHP_METHOD(SoapClient, __getLastRequest)
30243024
return;
30253025
}
30263026

3027-
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"), (void **)&tmp) == SUCCESS) {
3027+
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request", sizeof("__last_request"), (void **)&tmp) == SUCCESS &&
3028+
Z_TYPE_PP(tmp) == IS_STRING) {
30283029
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
30293030
}
30303031
RETURN_NULL();
@@ -3042,7 +3043,8 @@ PHP_METHOD(SoapClient, __getLastResponse)
30423043
return;
30433044
}
30443045

3045-
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"), (void **)&tmp) == SUCCESS) {
3046+
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response", sizeof("__last_response"), (void **)&tmp) == SUCCESS &&
3047+
Z_TYPE_PP(tmp) == IS_STRING) {
30463048
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
30473049
}
30483050
RETURN_NULL();
@@ -3060,7 +3062,8 @@ PHP_METHOD(SoapClient, __getLastRequestHeaders)
30603062
return;
30613063
}
30623064

3063-
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request_headers", sizeof("__last_request_headers"), (void **)&tmp) == SUCCESS) {
3065+
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_request_headers", sizeof("__last_request_headers"), (void **)&tmp) == SUCCESS &&
3066+
Z_TYPE_PP(tmp) == IS_STRING) {
30643067
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
30653068
}
30663069
RETURN_NULL();
@@ -3078,7 +3081,8 @@ PHP_METHOD(SoapClient, __getLastResponseHeaders)
30783081
return;
30793082
}
30803083

3081-
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response_headers", sizeof("__last_response_headers"), (void **)&tmp) == SUCCESS) {
3084+
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__last_response_headers", sizeof("__last_response_headers"), (void **)&tmp) == SUCCESS &&
3085+
Z_TYPE_PP(tmp) == IS_STRING) {
30823086
RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1);
30833087
}
30843088
RETURN_NULL();
@@ -3134,13 +3138,15 @@ PHP_METHOD(SoapClient, __setCookie)
31343138
}
31353139

31363140
if (val == NULL) {
3137-
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS) {
3141+
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS &&
3142+
Z_TYPE_PP(cookies) == IS_ARRAY) {
31383143
zend_hash_del(Z_ARRVAL_PP(cookies), name, name_len+1);
31393144
}
31403145
} else {
31413146
zval *zcookie;
31423147

3143-
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE) {
3148+
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE ||
3149+
Z_TYPE_PP(cookies) != IS_ARRAY) {
31443150
zval *tmp_cookies;
31453151

31463152
MAKE_STD_ZVAL(tmp_cookies);
@@ -3168,7 +3174,8 @@ PHP_METHOD(SoapClient, __getCookies)
31683174

31693175
array_init(return_value);
31703176

3171-
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) != FAILURE) {
3177+
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) != FAILURE &&
3178+
Z_TYPE_PP(cookies) == IS_ARRAY) {
31723179
zend_hash_copy(Z_ARRVAL_P(return_value), Z_ARRVAL_P(*cookies), (copy_ctor_func_t) zval_add_ref, (void *)&tmp, sizeof(zval*));
31733180
}
31743181
}
@@ -3990,7 +3997,8 @@ static xmlDocPtr serialize_response_call(sdlFunctionPtr function, char *function
39903997
}
39913998

39923999
if (version == SOAP_1_1) {
3993-
if (zend_hash_find(prop, "faultcode", sizeof("faultcode"), (void**)&tmp) == SUCCESS) {
4000+
if (zend_hash_find(prop, "faultcode", sizeof("faultcode"), (void**)&tmp) == SUCCESS &&
4001+
Z_TYPE_PP(tmp) == IS_STRING) {
39944002
size_t new_len;
39954003
xmlNodePtr node = xmlNewNode(NULL, BAD_CAST("faultcode"));
39964004
char *str = php_escape_html_entities((unsigned char*)Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), &new_len, 0, 0, NULL TSRMLS_CC);
@@ -4015,7 +4023,8 @@ static xmlDocPtr serialize_response_call(sdlFunctionPtr function, char *function
40154023
}
40164024
detail_name = "detail";
40174025
} else {
4018-
if (zend_hash_find(prop, "faultcode", sizeof("faultcode"), (void**)&tmp) == SUCCESS) {
4026+
if (zend_hash_find(prop, "faultcode", sizeof("faultcode"), (void**)&tmp) == SUCCESS &&
4027+
Z_TYPE_PP(tmp) == IS_STRING) {
40194028
size_t new_len;
40204029
xmlNodePtr node = xmlNewChild(param, ns, BAD_CAST("Code"), NULL);
40214030
char *str = php_escape_html_entities((unsigned char*)Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), &new_len, 0, 0, NULL TSRMLS_CC);
@@ -4255,7 +4264,8 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
42554264
}
42564265
}
42574266
} else {
4258-
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "style", sizeof("style"), (void **)&zstyle) == SUCCESS) {
4267+
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "style", sizeof("style"), (void **)&zstyle) == SUCCESS &&
4268+
Z_TYPE_PP(zstyle) == IS_LONG) {
42594269
style = Z_LVAL_PP(zstyle);
42604270
} else {
42614271
style = SOAP_RPC;
@@ -4278,7 +4288,7 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function
42784288
}
42794289

42804290
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "use", sizeof("use"), (void **)&zuse) == SUCCESS &&
4281-
Z_LVAL_PP(zuse) == SOAP_LITERAL) {
4291+
Z_TYPE_PP(zuse) == IS_LONG && Z_LVAL_PP(zuse) == SOAP_LITERAL) {
42824292
use = SOAP_LITERAL;
42834293
} else {
42844294
use = SOAP_ENCODED;
@@ -4408,6 +4418,7 @@ static xmlNodePtr serialize_parameter(sdlParamPtr param, zval *param_val, int in
44084418
zval **param_data;
44094419

44104420
if (zend_hash_find(Z_OBJPROP_P(param_val), "param_name", sizeof("param_name"), (void **)&param_name) == SUCCESS &&
4421+
Z_TYPE_PP(param_name) == IS_STRING &&
44114422
zend_hash_find(Z_OBJPROP_P(param_val), "param_data", sizeof("param_data"), (void **)&param_data) == SUCCESS) {
44124423
param_val = *param_data;
44134424
name = Z_STRVAL_PP(param_name);

main/main.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2580,19 +2580,21 @@ PHPAPI int php_execute_script(zend_file_handle *primary_file TSRMLS_DC)
25802580
zend_set_timeout(INI_INT("max_execution_time"), 0);
25812581
}
25822582

2583-
{
2584-
/*
2585-
If cli primary file has shabang line and there is a prepend file,
2586-
the `start_lineno` will be used by prepend file but not primary file,
2587-
save it and restore after prepend file been executed.
2588-
*/
2583+
/*
2584+
If cli primary file has shabang line and there is a prepend file,
2585+
the `start_lineno` will be used by prepend file but not primary file,
2586+
save it and restore after prepend file been executed.
2587+
*/
2588+
if (CG(start_lineno) && prepend_file_p) {
25892589
int orig_start_lineno = CG(start_lineno);
25902590

25912591
CG(start_lineno) = 0;
2592-
retval = (zend_execute_scripts(ZEND_REQUIRE TSRMLS_CC, NULL, 1, prepend_file_p) == SUCCESS);
2593-
CG(start_lineno) = orig_start_lineno;
2594-
2595-
retval = retval && (zend_execute_scripts(ZEND_REQUIRE TSRMLS_CC, NULL, 2, primary_file, append_file_p) == SUCCESS);
2592+
if (zend_execute_scripts(ZEND_REQUIRE TSRMLS_CC, NULL, 1, prepend_file_p) == SUCCESS) {
2593+
CG(start_lineno) = orig_start_lineno;
2594+
retval = (zend_execute_scripts(ZEND_REQUIRE TSRMLS_CC, NULL, 2, primary_file, append_file_p) == SUCCESS);
2595+
}
2596+
} else {
2597+
retval = (zend_execute_scripts(ZEND_REQUIRE TSRMLS_CC, NULL, 3, prepend_file_p, primary_file, append_file_p) == SUCCESS);
25962598
}
25972599
} zend_end_try();
25982600

0 commit comments

Comments
 (0)