diff options
Diffstat (limited to 'tests/libtest/lib569.c')
-rw-r--r-- | tests/libtest/lib569.c | 57 |
1 files changed, 34 insertions, 23 deletions
diff --git a/tests/libtest/lib569.c b/tests/libtest/lib569.c index 9c5d803b9..d5af4514e 100644 --- a/tests/libtest/lib569.c +++ b/tests/libtest/lib569.c @@ -31,7 +31,7 @@ int test(char *URL) char *rtsp_session_id; int request=1; int i; - FILE *idfile; + FILE *idfile = NULL; idfile = fopen(libtest_arg2, "wb"); if(idfile == NULL) { @@ -52,52 +52,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_SETUP); + test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP); res = curl_easy_perform(curl); if(res != CURLE_BAD_FUNCTION_ARGUMENT) { fprintf(stderr, "This should have failed. " "Cannot setup without a Transport: header"); - fclose(idfile); - return TEST_ERR_MAJOR_BAD; + res = TEST_ERR_MAJOR_BAD; + goto test_cleanup; } /* Go through the various Session IDs */ for(i = 0; i < 3; i++) { - 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; - curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP); - curl_easy_setopt(curl, CURLOPT_RTSP_TRANSPORT, - "Fake/NotReal/JustATest;foo=baz"); + test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP); + test_setopt(curl, CURLOPT_RTSP_TRANSPORT, "Fake/NotReal/JustATest;foo=baz"); res = curl_easy_perform(curl); - if(res) { - fclose(idfile); - return res; - } + if(res) + goto test_cleanup; curl_easy_getinfo(curl, CURLINFO_RTSP_SESSION_ID, &rtsp_session_id); fprintf(idfile, "Got Session ID: [%s]\n", rtsp_session_id); rtsp_session_id = NULL; - 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; - curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_TEARDOWN); - curl_easy_perform(curl); + test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_TEARDOWN); + res = curl_easy_perform(curl); /* Clear for the next go-round */ - curl_easy_setopt(curl, CURLOPT_RTSP_SESSION_ID, NULL); + test_setopt(curl, CURLOPT_RTSP_SESSION_ID, NULL); } - fclose(idfile); +test_cleanup: + + if(idfile) + fclose(idfile); + + if(stream_uri) + free(stream_uri); curl_easy_cleanup(curl); curl_global_cleanup(); |