aboutsummaryrefslogtreecommitdiff
path: root/tests/libtest/lib569.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/lib569.c
parent12d01bc5f72c4c0f9aabfa45628d9c4702491fb0 (diff)
Addes OOM handling for curl_easy_setopt() calls in test
Diffstat (limited to 'tests/libtest/lib569.c')
-rw-r--r--tests/libtest/lib569.c57
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();