curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder Daniel himself.

curl_easy_cleanup( ) causes segmentation fault

From: Chris V via curl-library <curl-library_at_lists.haxx.se>
Date: Wed, 25 Sep 2024 19:53:33 +0200

Hi,

I am trying to figure out why I am getting segfaults in my code.

Here is the c-code:

#include <curl/curl.h>

int main(void)
{
char *url="https://www.knebb.de/files/text.txt";
char *filename="/tmp/wetter.test";
CURL *curl_handle;
FILE *FI;
int r;

r=0;
/* init the curl session and set url*/
curl_handle = curl_easy_init();
curl_easy_setopt(curl_handle, CURLOPT_URL, url);
FI = fopen(filename, "w");
if(FI) {
     curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, FI);
     r = curl_easy_perform(curl_handle);
}
/* cleanup curl stuff */
curl_easy_cleanup(curl_handle);
r = fclose(FI);
printf("Fertig: %d\n",r);
}


I compile it with
gcc -o Beispiel beispiel.c -lcurl

Starting it I am getting a segfault. As soon as I remove the
curl_easy_cleanup() call it runs fine.

System is running on a Raspberry with Debian:
libcurl 7.64.0-4+deb10u9

Any ideas what I did wrong?

Thanks!

/KNEBB


-- 
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html
Received on 2024-09-25