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/lib570.c | |
parent | 12d01bc5f72c4c0f9aabfa45628d9c4702491fb0 (diff) |
Addes OOM handling for curl_easy_setopt() calls in test
Diffstat (limited to 'tests/libtest/lib570.c')
-rw-r--r-- | tests/libtest/lib570.c | 54 |
1 files changed, 35 insertions, 19 deletions
diff --git a/tests/libtest/lib570.c b/tests/libtest/lib570.c index 69a0168e0..f044f85e2 100644 --- a/tests/libtest/lib570.c +++ b/tests/libtest/lib570.c @@ -25,7 +25,7 @@ int test(char *URL) CURLcode res; CURL *curl; int request=1; - char *stream_uri; + char *stream_uri = NULL; if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); @@ -38,47 +38,63 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - curl_easy_setopt(curl, CURLOPT_HEADERDATA, stdout); - curl_easy_setopt(curl, CURLOPT_WRITEDATA, stdout); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + test_setopt(curl, CURLOPT_HEADERDATA, stdout); + test_setopt(curl, CURLOPT_WRITEDATA, stdout); + test_setopt(curl, CURLOPT_VERBOSE, 1L); - curl_easy_setopt(curl, CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_URL, URL); - curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS); + test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS); - stream_uri = suburl(URL, request++); - curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + if((stream_uri = suburl(URL, request++)) == NULL) { + res = TEST_ERR_MAJOR_BAD; + goto test_cleanup; + } + test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); free(stream_uri); + stream_uri = NULL; res = curl_easy_perform(curl); if(res != CURLE_RTSP_CSEQ_ERROR) { fprintf(stderr, "Failed to detect CSeq mismatch"); - return res; + res = TEST_ERR_MAJOR_BAD; + goto test_cleanup; } - curl_easy_setopt(curl, CURLOPT_RTSP_CLIENT_CSEQ, 999); - curl_easy_setopt(curl, CURLOPT_RTSP_TRANSPORT, - "RAW/RAW/UDP;unicast;client_port=3056-3057"); - curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP); + test_setopt(curl, CURLOPT_RTSP_CLIENT_CSEQ, 999); + test_setopt(curl, CURLOPT_RTSP_TRANSPORT, + "RAW/RAW/UDP;unicast;client_port=3056-3057"); + test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP); - stream_uri = suburl(URL, request++); - curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + if((stream_uri = suburl(URL, request++)) == NULL) { + res = TEST_ERR_MAJOR_BAD; + goto test_cleanup; + } + test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); free(stream_uri); + stream_uri = NULL; res = curl_easy_perform(curl); if(res) - return res; + goto test_cleanup; + + test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY); - curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY); - stream_uri = suburl(URL, request++); - curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI,stream_uri); + if((stream_uri = suburl(URL, request++)) == NULL) { + res = TEST_ERR_MAJOR_BAD; + goto test_cleanup; + } + test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); free(stream_uri); + stream_uri = NULL; res = curl_easy_perform(curl); if(res != CURLE_RTSP_SESSION_ERROR) { fprintf(stderr, "Failed to detect a Session ID mismatch"); } +test_cleanup: + curl_easy_cleanup(curl); curl_global_cleanup(); |