diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2017-09-05 17:41:22 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2017-09-05 17:41:22 +0200 |
commit | 166cb444b5986af8301ec69db78d96eb1139756e (patch) | |
tree | 68632a9a2446a49cbcbe39199b5bce8f9cbbbee6 | |
parent | 002856cd5c955e0e017598e2b007868a67ee02a8 (diff) | |
parent | dc00b6cf3f08835d4ad4275123a083bd390983c9 (diff) | |
download | php-git-166cb444b5986af8301ec69db78d96eb1139756e.tar.gz |
Merge branch 'PHP-7.2'
-rw-r--r-- | ext/soap/soap.c | 16 | ||||
-rw-r--r-- | ext/soap/tests/fault_warning.phpt | 28 |
2 files changed, 34 insertions, 10 deletions
diff --git a/ext/soap/soap.c b/ext/soap/soap.c index f1824e6b1d..13bfce90b2 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -891,16 +891,12 @@ PHP_METHOD(SoapFault, SoapFault) fault_code = Z_STRVAL_P(code); fault_code_len = Z_STRLEN_P(code); } else if (Z_TYPE_P(code) == IS_ARRAY && zend_hash_num_elements(Z_ARRVAL_P(code)) == 2) { - zval *t_ns, *t_code; - - zend_hash_internal_pointer_reset(Z_ARRVAL_P(code)); - t_ns = zend_hash_get_current_data(Z_ARRVAL_P(code)); - zend_hash_move_forward(Z_ARRVAL_P(code)); - t_code = zend_hash_get_current_data(Z_ARRVAL_P(code)); - if (Z_TYPE_P(t_ns) == IS_STRING && Z_TYPE_P(t_code) == IS_STRING) { - fault_code_ns = Z_STRVAL_P(t_ns); - fault_code = Z_STRVAL_P(t_code); - fault_code_len = Z_STRLEN_P(t_code); + zval *t_ns = zend_hash_index_find(Z_ARRVAL_P(code), 0); + zval *t_code = zend_hash_index_find(Z_ARRVAL_P(code), 1); + if (t_ns && t_code && Z_TYPE_P(t_ns) == IS_STRING && Z_TYPE_P(t_code) == IS_STRING) { + fault_code_ns = Z_STRVAL_P(t_ns); + fault_code = Z_STRVAL_P(t_code); + fault_code_len = Z_STRLEN_P(t_code); } else { php_error_docref(NULL, E_WARNING, "Invalid fault code"); return; diff --git a/ext/soap/tests/fault_warning.phpt b/ext/soap/tests/fault_warning.phpt new file mode 100644 index 0000000000..98d2d269ea --- /dev/null +++ b/ext/soap/tests/fault_warning.phpt @@ -0,0 +1,28 @@ +--TEST-- +SoapFault class: Invalid Fault code warning given? Can't be an empty string, an array of not 2 elements etc. +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +$fault = new SoapFault("", "message"); // Can't be an empty string +$fault = new SoapFault(0, "message"); // Can't be a non-string (except for null) +$fault = new SoapFault("Sender", "message"); +echo get_class($fault) . "\n"; +$fault = new SoapFault(null, "message"); +echo get_class($fault) . "\n"; +$fault = new SoapFault(["more"], "message"); // two elements in array required +$fault = new SoapFault(["m", "more", "superflous"], "message"); // two required +$fault = new SoapFault(["more-ns", "Sender"], "message"); // two given +echo get_class($fault); +?> +--EXPECTF-- +Warning: SoapFault::SoapFault(): Invalid fault code in %s on line %d + +Warning: SoapFault::SoapFault(): Invalid fault code in %s on line %d +SoapFault +SoapFault + +Warning: SoapFault::SoapFault(): Invalid fault code in %s on line %d + +Warning: SoapFault::SoapFault(): Invalid fault code in %s on line %d +SoapFault |