cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: cURL bug -- Segmentation Fault when timeout is 1 second

From: Gisle Vanem <gvanem_at_broadpark.no>
Date: Wed, 04 Feb 2009 18:32:22 +0100

"Daniel Marschall" <info_at_daniel-marschall.de> wrote:

> Here is my current C-Code (because I have switched from C++ to C):
>
> Still the same error. Is there some mistake I made?
...
> using namespace std;

It's still C++ afaics.

... * in writer() *

> strcat(buffer, data);
>

... * http_call() *
> char* buffer;
> curl_easy_setopt(curl, CURLOPT_WRITEDATA, buffer);

'buffer' isn't initialised to something. So no wonder writer()
crashes. With this patch:

@@ -66,7 +66,7 @@
     char errorBuffer[CURL_ERROR_SIZE];

     curl_easy_setopt (curl, CURLOPT_ERRORBUFFER, errorBuffer);
- char *buffer;
+ char *buffer = (char*)malloc(12345);

     curl_easy_setopt (curl, CURLOPT_WRITEDATA, buffer);
------------------

all works well here.

--gv
Received on 2009-02-04