lib1939.c (2319B)
1 /*************************************************************************** 2 * _ _ ____ _ 3 * Project ___| | | | _ \| | 4 * / __| | | | |_) | | 5 * | (__| |_| | _ <| |___ 6 * \___|\___/|_| \_\_____| 7 * 8 * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 9 * 10 * This software is licensed as described in the file COPYING, which 11 * you should have received as part of this distribution. The terms 12 * are also available at https://curl.se/docs/copyright.html. 13 * 14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell 15 * copies of the Software, and permit persons to whom the Software is 16 * furnished to do so, under the terms of the COPYING file. 17 * 18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 19 * KIND, either express or implied. 20 * 21 * SPDX-License-Identifier: curl 22 * 23 ***************************************************************************/ 24 #include "first.h" 25 26 #include "memdebug.h" 27 28 static CURLcode test_lib1939(char *URL) 29 { 30 CURLM *multi; 31 CURL *easy; 32 int running_handles; 33 34 curl_global_init(CURL_GLOBAL_DEFAULT); 35 36 multi = curl_multi_init(); 37 if(multi) { 38 easy = curl_easy_init(); 39 if(easy) { 40 CURLcode c; 41 CURLMcode m; 42 43 /* Crash only happens when using HTTPS */ 44 c = curl_easy_setopt(easy, CURLOPT_URL, URL); 45 if(!c) 46 /* Any old HTTP tunneling proxy will do here */ 47 c = curl_easy_setopt(easy, CURLOPT_PROXY, libtest_arg2); 48 49 if(!c) { 50 51 /* We're going to drive the transfer using multi interface here, 52 because we want to stop during the middle. */ 53 m = curl_multi_add_handle(multi, easy); 54 55 if(!m) 56 /* Run the multi handle once, just enough to start establishing an 57 HTTPS connection. */ 58 m = curl_multi_perform(multi, &running_handles); 59 60 if(m) 61 curl_mfprintf(stderr, "curl_multi_perform failed\n"); 62 } 63 /* Close the easy handle *before* the multi handle. Doing it the other 64 way around avoids the issue. */ 65 curl_easy_cleanup(easy); 66 } 67 curl_multi_cleanup(multi); /* double-free happens here */ 68 } 69 curl_global_cleanup(); 70 return CURLE_OK; 71 }