From cad9c3f55fad5da988144dc83ad76a8544a071a2 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 5 Feb 2010 18:07:19 +0000 Subject: Addes OOM handling for curl_easy_setopt() calls in test --- tests/libtest/lib503.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'tests/libtest/lib503.c') diff --git a/tests/libtest/lib503.c b/tests/libtest/lib503.c index 11f1150c0..3e8f3dc55 100644 --- a/tests/libtest/lib503.c +++ b/tests/libtest/lib503.c @@ -29,7 +29,7 @@ int test(char *URL) { CURL *c; - CURLM *m; + CURLM *m = NULL; int res = 0; int running; char done = FALSE; @@ -49,12 +49,12 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - curl_easy_setopt(c, CURLOPT_PROXY, libtest_arg2); /* set in first.c */ - curl_easy_setopt(c, CURLOPT_URL, URL); - curl_easy_setopt(c, CURLOPT_USERPWD, "test:ing"); - curl_easy_setopt(c, CURLOPT_PROXYUSERPWD, "test:ing"); - curl_easy_setopt(c, CURLOPT_HTTPPROXYTUNNEL, 1L); - curl_easy_setopt(c, CURLOPT_HEADER, 1L); + test_setopt(c, CURLOPT_PROXY, libtest_arg2); /* set in first.c */ + test_setopt(c, CURLOPT_URL, URL); + test_setopt(c, CURLOPT_USERPWD, "test:ing"); + test_setopt(c, CURLOPT_PROXYUSERPWD, "test:ing"); + test_setopt(c, CURLOPT_HTTPPROXYTUNNEL, 1L); + test_setopt(c, CURLOPT_HEADER, 1L); if ((m = curl_multi_init()) == NULL) { fprintf(stderr, "curl_multi_init() failed\n"); @@ -139,9 +139,13 @@ int test(char *URL) res = TEST_ERR_RUNS_FOREVER; } - curl_multi_remove_handle(m, c); +test_cleanup: + + if(m) { + curl_multi_remove_handle(m, c); + curl_multi_cleanup(m); + } curl_easy_cleanup(c); - curl_multi_cleanup(m); curl_global_cleanup(); return res; -- cgit v1.2.3