curl-library
Re: Issues with libCurl and OpenSSL
Date: Mon, 04 Aug 2003 11:01:44 +0800
I wrote a simple test program like so:
#include <curl/curl.h>
#include <curl/easy.h>
INT WINAPI
WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
INT nCmdShow)
{
CURL * curlCurlContext;
curlCurlContext = curl_easy_init();
if(curlCurlContext != NULL)
{
curl_easy_cleanup(curlCurlContext);
}
return 0;
}
Compiled it with OpenSSL 0.9.7 and libCurl 7.10.6 and I get memory
leaks. As far as I can tell this memory is being allocated by the
following call:
/* Lets get nice error messages */
SSL_load_error_strings();
in ssluse.c at line 413. So I poked around and found that
curl_easy_cleanup() doesn't cleanup the ssl error strings.
Amending my code by adding
curl_global_cleanup();
before the line 'return 0;' seemed to solve all the memory leaks. This
didn't seem to match my expectations, these memory leaks wouldn't cause
my program to grow to the sizes i was seeing. So I added some code to
make curl post to a URL (like my program was doing). Like so:
char * szPostField = "This is a test to locate memory leaks in our
software.";
curl_easy_setopt(curlCurlContext, CURLOPT_POSTFIELDS, szPostField);
curl_easy_setopt(curlCurlContext, CURLOPT_POSTFIELDSIZE,
strlen(szPostField));
curl_easy_setopt(curlCurlContext, CURLOPT_URL, "***https url***");
curl_easy_perform(curlCurlContext);
My server side script got the post data, the program then exits with the
following debug output:
Detected memory leaks!
Dumping objects ->
{3373} normal block at 0x009FC760, 12 bytes long.
Data: < > B0 C6 9F 00 00 00 00 00 06 00 00 00
...
{2986} normal block at 0x009F6BA0, 96 bytes long.
Data: <0l C C > 30 6C 9F 00 C7 05 43 00 BD 05 43 00 08 00 00 00
Object dump complete.
I may require some further analysis to locate these.
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
Received on 2003-08-04