cURL / Mailing Lists / curl-library / Single Mail

curl-library

Sigfault at easy_perform?

From: <nessup_at_cox.net>
Date: Fri, 17 Mar 2006 21:09:21 -0700

Hello,

For some strange reason I'm getting a sigfault when doing a curl easy
perform. The dump shows that the deepest function libcurl called was
getenv... any help here?

/** portion from main.c **/
...
     CURL *curl;
     lstp_t *session;

     (void)curl_global_init( CURL_GLOBAL_ALL );

     if( !(curl = curl_easy_init( )) ) {
         (void)fprintf( stderr, "Failed to load cURL.\n" );
         (void)curl_global_cleanup( );
         return (false);
     }
...

/** portion from lstp.c **/
...
#define SMART_REALLOC(ptr, size) \
             ((ptr) ? realloc( (ptr), (size) ) : malloc( (size) ))

struct swell_buffer {
     char *buffer;
     size_t size;
};
...
size_t
read_data( void *ptr, size_t size, size_t nmemb, void *stream )
{
     size_t realsize = (size * nmemb);
     struct swell_buffer *mem = (struct swell_buffer *)stream;

     (void)fprintf( stdout, "%s", (char *)ptr ); // debug

     mem->buffer = (char *)SMART_REALLOC(mem->buffer, (mem->size +
realsize + 1));
     if( mem->buffer ) {
         (void)memcpy( &mem->buffer[mem->size], ptr, realsize);
         mem->size += realsize;
         mem->buffer[mem->size] = 0;
     }

     return (realsize);
}
...
     CURLcode res;
     struct swell_buffer chunk;

     ...

     chunk.buffer = NULL;
     chunk.size = 0;

     (void)memset( session, 0, sizeof(lstp_t) );
     session->curl = curl;
     (void)memcpy( session->username, username, DSMEET_MAXUSERNAMELEN );
     (void)memcpy( session->password, password, DSMEET_MAXUSERNAMELEN );
     session->curr_status = 1;

     curl_easy_setopt( session->curl, CURLOPT_URL, ... );
     curl_easy_setopt( session->curl, CURLOPT_WRITEFUNCTION, read_data );
     curl_easy_setopt( session->curl, CURLOPT_WRITEDATA, (void *)&chunk
);
     curl_easy_setopt( session->curl, CURLOPT_USERAGENT, LSTP_USERAGENT
);
     //curl_easy_setopt( session->curl, CURLOPT_HTTPPOST, headerlist );

     if( (res = curl_easy_perform( session->curl )) < 0 ) { // SIGFAULT
         (void)fprintf( stderr, "Failed to log in. cURL error: %d\n",
res );
         return (ERR_CURL);
     }
...

Please cc to me.

--ness
Received on 2006-03-18