summaryrefslogtreecommitdiff
path: root/tests/libtest/lib525.c
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2010-02-05 18:07:19 +0000
committerYang Tse <yangsita@gmail.com>2010-02-05 18:07:19 +0000
commitcad9c3f55fad5da988144dc83ad76a8544a071a2 (patch)
tree9231f49bc11dfdb69b4cac9af3b1dd473d1507ad /tests/libtest/lib525.c
parent12d01bc5f72c4c0f9aabfa45628d9c4702491fb0 (diff)
downloadgnurl-cad9c3f55fad5da988144dc83ad76a8544a071a2.tar.gz
gnurl-cad9c3f55fad5da988144dc83ad76a8544a071a2.tar.bz2
gnurl-cad9c3f55fad5da988144dc83ad76a8544a071a2.zip
Addes OOM handling for curl_easy_setopt() calls in test
Diffstat (limited to 'tests/libtest/lib525.c')
-rw-r--r--tests/libtest/lib525.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/tests/libtest/lib525.c b/tests/libtest/lib525.c
index c503d1618..41a519e7e 100644
--- a/tests/libtest/lib525.c
+++ b/tests/libtest/lib525.c
@@ -30,7 +30,7 @@ int test(char *URL)
struct_stat file_info;
int running;
char done=FALSE;
- CURLM *m;
+ CURLM *m = NULL;
struct timeval ml_start;
struct timeval mp_start;
char ml_timedout = FALSE;
@@ -72,19 +72,19 @@ int test(char *URL)
}
/* enable uploading */
- curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
+ test_setopt(curl, CURLOPT_UPLOAD, 1L);
/* specify target */
- curl_easy_setopt(curl,CURLOPT_URL, URL);
+ test_setopt(curl,CURLOPT_URL, URL);
/* go verbose */
- curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
+ test_setopt(curl, CURLOPT_VERBOSE, 1L);
/* use active FTP */
- curl_easy_setopt(curl, CURLOPT_FTPPORT, "-");
+ test_setopt(curl, CURLOPT_FTPPORT, "-");
/* now specify which file to upload */
- curl_easy_setopt(curl, CURLOPT_READDATA, hd_src);
+ test_setopt(curl, CURLOPT_READDATA, hd_src);
/* NOTE: if you want this code to work on Windows with libcurl as a DLL, you
MUST also provide a read callback with CURLOPT_READFUNCTION. Failing to
@@ -95,7 +95,7 @@ int test(char *URL)
option you MUST make sure that the type of the passed-in argument is a
curl_off_t. If you use CURLOPT_INFILESIZE (without _LARGE) you must
make sure that to pass in a type 'long' argument. */
- curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE,
+ test_setopt(curl, CURLOPT_INFILESIZE_LARGE,
(curl_off_t)file_info.st_size);
if ((m = curl_multi_init()) == NULL) {
@@ -183,16 +183,22 @@ int test(char *URL)
res = TEST_ERR_RUNS_FOREVER;
}
+test_cleanup:
+
#ifdef LIB529
/* test 529 */
- curl_multi_remove_handle(m, curl);
- curl_multi_cleanup(m);
+ if(m) {
+ curl_multi_remove_handle(m, curl);
+ curl_multi_cleanup(m);
+ }
curl_easy_cleanup(curl);
#else
/* test 525 */
- curl_multi_remove_handle(m, curl);
+ if(m)
+ curl_multi_remove_handle(m, curl);
curl_easy_cleanup(curl);
- curl_multi_cleanup(m);
+ if(m)
+ curl_multi_cleanup(m);
#endif
fclose(hd_src); /* close the local file */