Hi Dan, 

I have used mutex callbacks, however the issue of server going into a hang
state still persisted. Below is a code snippet where I suspect the issue is
present. 

---------------------------------------------------------------------------

    curlRC = curl_easy_perform(curl);
    if(curlRC != CURLE_OK )
      {
         //! Return curl error if any.
        pError=(char *)curl_easy_strerror(curlRC);

        pResponse=(char *) malloc (strlen(pError)+ 26);
        if (!pResponse) return NULL;

        memset(pResponse,'\0',(strlen(pError)+ 26));
        strncpy(pResponse,"<cURL_ERROR>",12);
        strncat(pResponse,pError,strlen(pError));
        strncat(pResponse,"</cURL_ERROR>",13);

        free(pError); // Commenting this line had solved the issue.
      }
      
      curl_slist_free_all(headerlist);
      curl_easy_cleanup(curl); 
---------------------------------------------------------------------------

My issue seems to be solved after commenting the "free(pError);" as shown
above.

I am freeing "pError" which is returned by curl_easy_strerror(). 
Does curl_easy_strerror() allocate memory for the returned string internally
and does curl_easy_cleanup(curl) try to freeup that allocated memory ?

If that is so then, this code was trying to freeup same memory location
twice (once in "free(pError)" and again in curl_easy_cleanup) and hence
causing the issue. Do you think this observation make any sense?

Thanks,
San.

Reply via email to