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/lib555.c | |
parent | 12d01bc5f72c4c0f9aabfa45628d9c4702491fb0 (diff) | |
download | curl-cad9c3f55fad5da988144dc83ad76a8544a071a2.tar.gz |
Addes OOM handling for curl_easy_setopt() calls in test
Diffstat (limited to 'tests/libtest/lib555.c')
-rw-r--r-- | tests/libtest/lib555.c | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/tests/libtest/lib555.c b/tests/libtest/lib555.c index 0b9d27ae0..e5628a6d5 100644 --- a/tests/libtest/lib555.c +++ b/tests/libtest/lib555.c @@ -64,7 +64,7 @@ int test(char *URL) int res; CURL *curl; int counter=0; - CURLM *m; + CURLM *m = NULL; int running=1; struct timeval mp_start; char mp_timedout = FALSE; @@ -80,26 +80,26 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - curl_easy_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); - curl_easy_setopt(curl, CURLOPT_HEADER, 1L); + test_setopt(curl, CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_VERBOSE, 1L); + test_setopt(curl, CURLOPT_HEADER, 1L); /* read the POST data from a callback */ - curl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctlcallback); - curl_easy_setopt(curl, CURLOPT_IOCTLDATA, &counter); - curl_easy_setopt(curl, CURLOPT_READFUNCTION, readcallback); - curl_easy_setopt(curl, CURLOPT_READDATA, &counter); + test_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctlcallback); + test_setopt(curl, CURLOPT_IOCTLDATA, &counter); + test_setopt(curl, CURLOPT_READFUNCTION, readcallback); + test_setopt(curl, CURLOPT_READDATA, &counter); /* We CANNOT do the POST fine without setting the size (or choose chunked)! */ - curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, strlen(UPLOADTHIS)); + test_setopt(curl, CURLOPT_POSTFIELDSIZE, strlen(UPLOADTHIS)); - curl_easy_setopt(curl, CURLOPT_POST, 1L); + test_setopt(curl, CURLOPT_POST, 1L); #ifdef CURL_DOES_CONVERSIONS /* Convert the POST data to ASCII. */ - curl_easy_setopt(curl, CURLOPT_TRANSFERTEXT, 1L); + test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L); #endif - curl_easy_setopt(curl, CURLOPT_PROXY, libtest_arg2); - curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, libtest_arg3); - curl_easy_setopt(curl, CURLOPT_PROXYAUTH, + test_setopt(curl, CURLOPT_PROXY, libtest_arg2); + test_setopt(curl, CURLOPT_PROXYUSERPWD, libtest_arg3); + test_setopt(curl, CURLOPT_PROXYAUTH, (long) (CURLAUTH_NTLM | CURLAUTH_DIGEST | CURLAUTH_BASIC) ); if ((m = curl_multi_init()) == NULL) { @@ -144,10 +144,13 @@ int test(char *URL) res = TEST_ERR_RUNS_FOREVER; } - curl_multi_remove_handle(m, curl); - curl_easy_cleanup(curl); - curl_multi_cleanup(m); +test_cleanup: + if(m) { + curl_multi_remove_handle(m, curl); + curl_multi_cleanup(m); + } + curl_easy_cleanup(curl); curl_global_cleanup(); return res; |