com php-src: fix warning & improve error handling in CURL: ext/curl/interface.c

From: Date: Mon, 23 Mar 2015 04:51:58 +0000
Subject: com php-src: fix warning & improve error handling in CURL: ext/curl/interface.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-85801@lists.php.net to get a copy of this message
Commit: 6929089db077ff2b1a941b9bf3d130972cde6636 Author: Stanislav Malyshev <stas@php.net> Sun, 22 Mar 2015 21:51:58 -0700 Parents: 62859309b075db8ebdf94c2b6e87f1a1a405fb3e Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=6929089db077ff2b1a941b9bf3d130972cde6636 Log: fix warning & improve error handling in CURL Changed paths: M ext/curl/interface.c Diff: diff --git a/ext/curl/interface.c b/ext/curl/interface.c index 6b9611d..85cb33d 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -2505,6 +2505,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{ zend_ulong num_key; struct HttpPost *first = NULL; struct HttpPost *last = NULL; + CURLFORMcode form_error; postfields = HASH_OF(zvalue); if (!postfields) { @@ -2545,13 +2546,17 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{ if (Z_TYPE_P(prop) == IS_STRING && Z_STRLEN_P(prop) > 0) { filename = Z_STRVAL_P(prop); } - error = curl_formadd(&first, &last, + form_error = curl_formadd(&first, &last, CURLFORM_COPYNAME, string_key->val, CURLFORM_NAMELENGTH, string_key->len, CURLFORM_FILENAME, filename ? filename : postval, CURLFORM_CONTENTTYPE, type ? type : "application/octet-stream", CURLFORM_FILE, postval, CURLFORM_END); + if (form_error != CURL_FORMADD_OK) { + /* Not nice to convert between enums but we only have place for one error type */ + error = (CURLcode)form_error; + } } zend_string_release(string_key); @@ -2566,13 +2571,17 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{ /* The arguments after _NAMELENGTH and _CONTENTSLENGTH * must be explicitly cast to long in curl_formadd * use since curl needs a long not an int. */ - error = curl_formadd(&first, &last, + form_error = curl_formadd(&first, &last, CURLFORM_COPYNAME, string_key->val, CURLFORM_NAMELENGTH, (zend_long)string_key->len, CURLFORM_COPYCONTENTS, postval, CURLFORM_CONTENTSLENGTH, (zend_long)Z_STRLEN_P(current), CURLFORM_END); + if (form_error != CURL_FORMADD_OK) { + /* Not nice to convert between enums but we only have place for one error type */ + error = (CURLcode)form_error; + } zend_string_release(string_key); } ZEND_HASH_FOREACH_END();

« previous php.cvs (#85801) next »