lib1939.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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.haxx.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 "test.h"
  25. #include "memdebug.h"
  26. int test(char *URL)
  27. {
  28. CURLM *multi;
  29. CURL *easy;
  30. int running_handles;
  31. curl_global_init(CURL_GLOBAL_DEFAULT);
  32. multi = curl_multi_init();
  33. if(multi) {
  34. easy = curl_easy_init();
  35. if(easy) {
  36. CURLcode c;
  37. CURLMcode m;
  38. /* Crash only happens when using HTTPS */
  39. c = curl_easy_setopt(easy, CURLOPT_URL, URL);
  40. if(!c)
  41. /* Any old HTTP tunneling proxy will do here */
  42. c = curl_easy_setopt(easy, CURLOPT_PROXY, libtest_arg2);
  43. if(!c) {
  44. /* We're going to drive the transfer using multi interface here,
  45. because we want to stop during the middle. */
  46. m = curl_multi_add_handle(multi, easy);
  47. if(!m)
  48. /* Run the multi handle once, just enough to start establishing an
  49. HTTPS connection. */
  50. m = curl_multi_perform(multi, &running_handles);
  51. if(m)
  52. fprintf(stderr, "curl_multi_perform failed\n");
  53. }
  54. /* Close the easy handle *before* the multi handle. Doing it the other
  55. way around avoids the issue. */
  56. curl_easy_cleanup(easy);
  57. }
  58. curl_multi_cleanup(multi); /* double-free happens here */
  59. }
  60. curl_global_cleanup();
  61. return CURLE_OK;
  62. }