diff options
author | Yang Tse <yangsita@gmail.com> | 2010-02-05 18:07:19 +0000 |
---|---|---|
committer | Yang Tse <yangsita@gmail.com> | 2010-02-05 18:07:19 +0000 |
commit | cad9c3f55fad5da988144dc83ad76a8544a071a2 (patch) | |
tree | 9231f49bc11dfdb69b4cac9af3b1dd473d1507ad /tests/libtest/lib530.c | |
parent | 12d01bc5f72c4c0f9aabfa45628d9c4702491fb0 (diff) | |
download | curl-cad9c3f55fad5da988144dc83ad76a8544a071a2.tar.gz |
Addes OOM handling for curl_easy_setopt() calls in test
Diffstat (limited to 'tests/libtest/lib530.c')
-rw-r--r-- | tests/libtest/lib530.c | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/tests/libtest/lib530.c b/tests/libtest/lib530.c index d738277f2..ef2218834 100644 --- a/tests/libtest/lib530.c +++ b/tests/libtest/lib530.c @@ -69,13 +69,47 @@ int test(char *URL) } sprintf(target_url, "%s%04i", URL, i + 1); target_url[sizeof(target_url) - 1] = '\0'; - curl_easy_setopt(curl[i], CURLOPT_URL, target_url); + + res = curl_easy_setopt(curl[i], CURLOPT_URL, target_url); + if(res) { + fprintf(stderr, "curl_easy_setopt() failed " + "on handle #%d\n", i); + for (j=i; j >= 0; j--) { + curl_multi_remove_handle(m, curl[j]); + curl_easy_cleanup(curl[j]); + } + curl_multi_cleanup(m); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD + i; + } /* go verbose */ - curl_easy_setopt(curl[i], CURLOPT_VERBOSE, 1L); + res = curl_easy_setopt(curl[i], CURLOPT_VERBOSE, 1L); + if(res) { + fprintf(stderr, "curl_easy_setopt() failed " + "on handle #%d\n", i); + for (j=i; j >= 0; j--) { + curl_multi_remove_handle(m, curl[j]); + curl_easy_cleanup(curl[j]); + } + curl_multi_cleanup(m); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD + i; + } /* include headers */ - curl_easy_setopt(curl[i], CURLOPT_HEADER, 1L); + res = curl_easy_setopt(curl[i], CURLOPT_HEADER, 1L); + if(res) { + fprintf(stderr, "curl_easy_setopt() failed " + "on handle #%d\n", i); + for (j=i; j >= 0; j--) { + curl_multi_remove_handle(m, curl[j]); + curl_easy_cleanup(curl[j]); + } + curl_multi_cleanup(m); + curl_global_cleanup(); + return TEST_ERR_MAJOR_BAD + i; + } /* add handle to multi */ if ((res = (int)curl_multi_add_handle(m, curl[i])) != CURLM_OK) { @@ -163,6 +197,8 @@ int test(char *URL) res = TEST_ERR_RUNS_FOREVER; } +test_cleanup: + /* cleanup NUM_HANDLES easy handles */ for(i=0; i < NUM_HANDLES; i++) { curl_multi_remove_handle(m, curl[i]); |