summaryrefslogtreecommitdiff
path: root/tests/libtest/lib540.c
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2011-10-07 20:50:57 +0200
committerYang Tse <yangsita@gmail.com>2011-10-07 20:50:57 +0200
commit17f48fe87979f159e2d8769d678641c60f4c0eed (patch)
tree322c1d34d9c8d0a4d203d127765818f297ac93c7 /tests/libtest/lib540.c
parentb82bd05354cfa756a013d2bed4ffdc951ce903db (diff)
downloadcurl-17f48fe87979f159e2d8769d678641c60f4c0eed.tar.gz
libcurl: some OOM handling fixes
Diffstat (limited to 'tests/libtest/lib540.c')
-rw-r--r--tests/libtest/lib540.c41
1 files changed, 33 insertions, 8 deletions
diff --git a/tests/libtest/lib540.c b/tests/libtest/lib540.c
index 8fb409f07..467e87dc4 100644
--- a/tests/libtest/lib540.c
+++ b/tests/libtest/lib540.c
@@ -49,23 +49,45 @@ static int init(CURLM *cm, const char* url, const char* userpwd,
}
res = curl_easy_setopt(eh, CURLOPT_URL, url);
- if(res) return 1;
+ if(res) {
+ curl_easy_cleanup(eh);
+ return 1;
+ }
res = curl_easy_setopt(eh, CURLOPT_PROXY, PROXY);
- if(res) return 1;
+ if(res) {
+ curl_easy_cleanup(eh);
+ return 1;
+ }
res = curl_easy_setopt(eh, CURLOPT_PROXYUSERPWD, userpwd);
- if(res) return 1;
+ if(res) {
+ curl_easy_cleanup(eh);
+ return 1;
+ }
res = curl_easy_setopt(eh, CURLOPT_PROXYAUTH, (long)CURLAUTH_ANY);
- if(res) return 1;
+ if(res) {
+ curl_easy_cleanup(eh);
+ return 1;
+ }
res = curl_easy_setopt(eh, CURLOPT_VERBOSE, 1L);
- if(res) return 1;
+ if(res) {
+ curl_easy_cleanup(eh);
+ return 1;
+ }
res = curl_easy_setopt(eh, CURLOPT_HEADER, 1L);
- if(res) return 1;
+ if(res) {
+ curl_easy_cleanup(eh);
+ return 1;
+ }
res = curl_easy_setopt(eh, CURLOPT_HTTPHEADER, headers); /* custom Host: */
- if(res) return 1;
+ if(res) {
+ curl_easy_cleanup(eh);
+ return 1;
+ }
if ((res = (int)curl_multi_add_handle(cm, eh)) != CURLM_OK) {
fprintf(stderr, "curl_multi_add_handle() failed, "
"with code %d\n", res);
+ curl_easy_cleanup(eh);
return 1; /* failure */
}
@@ -80,13 +102,16 @@ static int loop(CURLM *cm, const char* url, const char* userpwd,
int M, Q, U = -1;
fd_set R, W, E;
struct timeval T;
+ CURLMcode rc;
if(init(cm, url, userpwd, headers))
return 1; /* failure */
while (U) {
- (void) curl_multi_perform(cm, &U);
+ rc = curl_multi_perform(cm, &U);
+ if(rc == CURLM_OUT_OF_MEMORY)
+ return 1; /* failure */
if (U) {
FD_ZERO(&R);