Advertisement
Guest User

libcurl memory leak

a guest
Sep 18th, 2012
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.78 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <curl/curl.h>
  4.  
  5. int main(int argc, char* argv[])
  6. {
  7.   int i = 0;
  8.   CURL *hnd = NULL;
  9.   FILE *header;
  10.   FILE *body;
  11.  
  12.   if(argc < 2)
  13.   {
  14.     printf("Wat?\n");
  15.     return 1;
  16.   }
  17.  
  18.   curl_global_init(CURL_GLOBAL_ALL);
  19.   hnd = curl_easy_init();
  20.   curl_easy_setopt(hnd, CURLOPT_INTERFACE, "lo");
  21.  
  22.   while(1)
  23.   {
  24.     printf("Round %d\n", ++i);
  25.     curl_easy_setopt(hnd, CURLOPT_URL, argv[1]);
  26.     header = fopen("/dev/null", "w+");
  27.     body = fopen("/dev/null", "w+");
  28.     curl_easy_setopt(hnd, CURLOPT_WRITEHEADER, header);
  29.     curl_easy_setopt(hnd, CURLOPT_WRITEDATA, body);
  30.     curl_easy_perform(hnd);
  31.     fclose(header);
  32.     fclose(body);
  33.     if(i == 10)
  34.     {
  35.       curl_easy_cleanup(hnd);
  36.       return 0;
  37.     }
  38.   }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement