From 067e240321ea8320a32a1c751769f9e625b1af4b Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 30 Jul 2026 10:08:58 +0200 Subject: [PATCH] add Daniel's extra check, pass NULL on init more, apply to 5000 --- tests/libtest/lib5000.c | 4 +++- tests/libtest/lib5004.c | 18 +++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/tests/libtest/lib5000.c b/tests/libtest/lib5000.c index a0eb92f0ae..05c5b99ac4 100644 --- a/tests/libtest/lib5000.c +++ b/tests/libtest/lib5000.c @@ -50,7 +50,9 @@ static CURLcode test_lib5000(const char *URL) easy_setopt(curl, CURLOPT_HEADER, 0L); easy_setopt(curl, CURLOPT_URL, URL); if(libtest_arg2) { - connect_to = curl_slist_append(connect_to, libtest_arg2); + connect_to = curl_slist_append(NULL, libtest_arg2); + if(!connect_to) + goto test_cleanup; } easy_setopt(curl, CURLOPT_CONNECT_TO, connect_to); diff --git a/tests/libtest/lib5004.c b/tests/libtest/lib5004.c index 33945e867f..767bec410a 100644 --- a/tests/libtest/lib5004.c +++ b/tests/libtest/lib5004.c @@ -34,6 +34,7 @@ static CURLcode test_lib5004(const char *URL) CURLcode result = TEST_ERR_MAJOR_BAD; struct curl_slist *connect_to = NULL; struct curl_slist *headers = NULL; + struct curl_slist *nheaders; if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { curl_mfprintf(stderr, "curl_global_init() failed\n"); @@ -60,14 +61,25 @@ static CURLcode test_lib5004(const char *URL) headers = curl_slist_append(NULL, "Date: Tue, 20 Apr 2021 02:07:55 GMT"); if(!headers) goto test_cleanup; - curl_slist_append(headers, "Content-Type: application/json"); - curl_slist_append(headers, "Content-Length: 18"); + + nheaders = curl_slist_append(headers, "Content-Type: application/json"); + if(!nheaders) + goto test_cleanup; + headers = nheaders; + + nheaders = curl_slist_append(headers, "Content-Length: 18"); + if(!nheaders) + goto test_cleanup; + headers = nheaders; + easy_setopt(curl, CURLOPT_HTTPHEADER, headers); easy_setopt(curl, CURLOPT_HEADER, 0L); easy_setopt(curl, CURLOPT_URL, URL); if(libtest_arg2) { - connect_to = curl_slist_append(connect_to, libtest_arg2); + connect_to = curl_slist_append(NULL, libtest_arg2); + if(!connect_to) + goto test_cleanup; } easy_setopt(curl, CURLOPT_CONNECT_TO, connect_to);