From 70c3ed48ac737ab7fa83600313cf4bd9c2443ee5 Mon Sep 17 00:00:00 2001 From: Patrick Monnerat Date: Sun, 8 Oct 2017 19:05:59 +0100 Subject: test643: verify curl_mime_subparts() rejects cyclic additions. --- tests/libtest/lib643.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'tests/libtest') diff --git a/tests/libtest/lib643.c b/tests/libtest/lib643.c index e26a2515f..7432dfce8 100644 --- a/tests/libtest/lib643.c +++ b/tests/libtest/lib643.c @@ -251,6 +251,30 @@ test_cleanup: return res; } +static int cyclic_add(void) +{ + CURL *easy = curl_easy_init(); + curl_mime *mime = curl_mime_init(easy); + curl_mimepart *part = curl_mime_addpart(mime); + CURLcode a1 = curl_mime_subparts(part, mime); + + if(a1 == CURLE_BAD_FUNCTION_ARGUMENT) { + curl_mime *submime = curl_mime_init(easy); + curl_mimepart *subpart = curl_mime_addpart(submime); + + curl_mime_subparts(part, submime); + a1 = curl_mime_subparts(subpart, mime); + } + + curl_mime_free(mime); + curl_easy_cleanup(easy); + if(a1 != CURLE_BAD_FUNCTION_ARGUMENT) + /* that should have failed */ + return 1; + + return 0; +} + int test(char *URL) { int res; @@ -264,6 +288,9 @@ int test(char *URL) if(!res) res = once(URL, FALSE); /* new */ + if(!res) + res = cyclic_add(); + curl_global_cleanup(); return res; -- cgit v1.2.1