From: Daniel Stenberg Date: Mon, 28 Aug 2023 06:29:15 +0000 (+0200) Subject: libtest: use curl_free() to free libcurl allocated data X-Git-Tag: curl-8_3_0~96 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a06de2b772cd99c1f8fa9f61717853ddd0009d4d;p=thirdparty%2Fcurl.git libtest: use curl_free() to free libcurl allocated data In several test programs. These mistakes are not detected or a problem as long as memdebug.h is included, as that provides the debug wrappers for all memory functions in the same style libcurl internals do it, which makes curl_free and free effectively the same call. Reported-by: Nicholas Nethercote Closes #11746 --- diff --git a/tests/libtest/lib539.c b/tests/libtest/lib539.c index 0e8aada4b7..75f146c002 100644 --- a/tests/libtest/lib539.c +++ b/tests/libtest/lib539.c @@ -70,7 +70,7 @@ int test(char *URL) slist = curl_slist_append(NULL, "SYST"); if(!slist) { - free(newURL); + curl_free(newURL); curl_easy_cleanup(curl); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; @@ -85,7 +85,7 @@ int test(char *URL) test_cleanup: curl_slist_free_all(slist); - free(newURL); + curl_free(newURL); curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib568.c b/tests/libtest/lib568.c index 9e761e8da5..97304fa58a 100644 --- a/tests/libtest/lib568.c +++ b/tests/libtest/lib568.c @@ -75,7 +75,7 @@ int test(char *URL) goto test_cleanup; } test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); - free(stream_uri); + curl_free(stream_uri); stream_uri = NULL; sdp = open(libtest_arg2, O_RDONLY); @@ -110,7 +110,7 @@ int test(char *URL) goto test_cleanup; } test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); - free(stream_uri); + curl_free(stream_uri); stream_uri = NULL; test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_DESCRIBE); @@ -126,7 +126,7 @@ int test(char *URL) goto test_cleanup; } test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); - free(stream_uri); + curl_free(stream_uri); stream_uri = NULL; custom_headers = curl_slist_append(custom_headers, @@ -156,7 +156,7 @@ int test(char *URL) goto test_cleanup; } test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); - free(stream_uri); + curl_free(stream_uri); stream_uri = NULL; test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS); @@ -167,7 +167,7 @@ test_cleanup: if(sdpf) fclose(sdpf); - free(stream_uri); + curl_free(stream_uri); if(custom_headers) curl_slist_free_all(custom_headers); diff --git a/tests/libtest/lib569.c b/tests/libtest/lib569.c index a66d07bc27..da95bb9558 100644 --- a/tests/libtest/lib569.c +++ b/tests/libtest/lib569.c @@ -85,7 +85,7 @@ int test(char *URL) goto test_cleanup; } test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); - free(stream_uri); + curl_free(stream_uri); stream_uri = NULL; test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP); @@ -105,7 +105,7 @@ int test(char *URL) goto test_cleanup; } test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); - free(stream_uri); + curl_free(stream_uri); stream_uri = NULL; test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_TEARDOWN); @@ -120,7 +120,7 @@ test_cleanup: if(idfile) fclose(idfile); - free(stream_uri); + curl_free(stream_uri); curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib570.c b/tests/libtest/lib570.c index b415244167..392c398a8f 100644 --- a/tests/libtest/lib570.c +++ b/tests/libtest/lib570.c @@ -63,7 +63,7 @@ int test(char *URL) goto test_cleanup; } test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); - free(stream_uri); + curl_free(stream_uri); stream_uri = NULL; res = curl_easy_perform(curl); @@ -84,7 +84,7 @@ int test(char *URL) goto test_cleanup; } test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); - free(stream_uri); + curl_free(stream_uri); stream_uri = NULL; res = curl_easy_perform(curl); @@ -99,7 +99,7 @@ int test(char *URL) goto test_cleanup; } test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); - free(stream_uri); + curl_free(stream_uri); stream_uri = NULL; res = curl_easy_perform(curl); @@ -112,7 +112,7 @@ int test(char *URL) } test_cleanup: - free(stream_uri); + curl_free(stream_uri); curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib571.c b/tests/libtest/lib571.c index 86106b21ea..60b4b36e01 100644 --- a/tests/libtest/lib571.c +++ b/tests/libtest/lib571.c @@ -134,7 +134,7 @@ int test(char *URL) goto test_cleanup; } test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); - free(stream_uri); + curl_free(stream_uri); stream_uri = NULL; test_setopt(curl, CURLOPT_INTERLEAVEFUNCTION, rtp_write); @@ -156,7 +156,7 @@ int test(char *URL) goto test_cleanup; } test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); - free(stream_uri); + curl_free(stream_uri); stream_uri = NULL; test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY); @@ -171,7 +171,7 @@ int test(char *URL) goto test_cleanup; } test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); - free(stream_uri); + curl_free(stream_uri); stream_uri = NULL; test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_DESCRIBE); @@ -185,7 +185,7 @@ int test(char *URL) goto test_cleanup; } test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); - free(stream_uri); + curl_free(stream_uri); stream_uri = NULL; test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY); @@ -203,7 +203,7 @@ int test(char *URL) } test_cleanup: - free(stream_uri); + curl_free(stream_uri); if(protofile) fclose(protofile); diff --git a/tests/libtest/lib572.c b/tests/libtest/lib572.c index f21037dc2f..b199c48956 100644 --- a/tests/libtest/lib572.c +++ b/tests/libtest/lib572.c @@ -78,7 +78,7 @@ int test(char *URL) goto test_cleanup; } test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); - free(stream_uri); + curl_free(stream_uri); stream_uri = NULL; test_setopt(curl, CURLOPT_RTSP_TRANSPORT, "Planes/Trains/Automobiles"); @@ -93,7 +93,7 @@ int test(char *URL) goto test_cleanup; } test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); - free(stream_uri); + curl_free(stream_uri); stream_uri = NULL; /* PUT style GET_PARAMETERS */ @@ -128,7 +128,7 @@ int test(char *URL) goto test_cleanup; } test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); - free(stream_uri); + curl_free(stream_uri); stream_uri = NULL; res = curl_easy_perform(curl); @@ -143,7 +143,7 @@ int test(char *URL) goto test_cleanup; } test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); - free(stream_uri); + curl_free(stream_uri); stream_uri = NULL; test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_GET_PARAMETER); @@ -162,7 +162,7 @@ int test(char *URL) goto test_cleanup; } test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri); - free(stream_uri); + curl_free(stream_uri); stream_uri = NULL; test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS); @@ -173,7 +173,7 @@ test_cleanup: if(paramsf) fclose(paramsf); - free(stream_uri); + curl_free(stream_uri); if(custom_headers) curl_slist_free_all(custom_headers); diff --git a/tests/libtest/lib661.c b/tests/libtest/lib661.c index d51608c8c2..6478ddbf59 100644 --- a/tests/libtest/lib661.c +++ b/tests/libtest/lib661.c @@ -52,7 +52,7 @@ int test(char *URL) test_setopt(curl, CURLOPT_FTP_FILEMETHOD, (long) CURLFTPMETHOD_SINGLECWD); res = curl_easy_perform(curl); - free(newURL); + curl_free(newURL); newURL = aprintf("%s/folderB/661", URL); test_setopt(curl, CURLOPT_URL, newURL); res = curl_easy_perform(curl); @@ -67,7 +67,7 @@ int test(char *URL) goto test_cleanup; } - free(newURL); + curl_free(newURL); newURL = aprintf("%s/folderA/661", URL); test_setopt(curl, CURLOPT_URL, newURL); test_setopt(curl, CURLOPT_VERBOSE, 1L); @@ -76,13 +76,13 @@ int test(char *URL) res = curl_easy_perform(curl); /* curve ball: CWD /folderB before reusing connection with _NOCWD */ - free(newURL); + curl_free(newURL); newURL = aprintf("%s/folderB/661", URL); test_setopt(curl, CURLOPT_URL, newURL); test_setopt(curl, CURLOPT_FTP_FILEMETHOD, (long) CURLFTPMETHOD_SINGLECWD); res = curl_easy_perform(curl); - free(newURL); + curl_free(newURL); newURL = aprintf("%s/folderA/661", URL); test_setopt(curl, CURLOPT_URL, newURL); test_setopt(curl, CURLOPT_FTP_FILEMETHOD, (long) CURLFTPMETHOD_NOCWD); @@ -144,7 +144,7 @@ int test(char *URL) test_cleanup: curl_slist_free_all(slist); - free(newURL); + curl_free(newURL); curl_easy_cleanup(curl); curl_global_cleanup();