mirror of
https://github.com/moparisthebest/curl
synced 2025-01-04 18:38:03 -05:00
Prevent multiple initialization of memdebug configuration variables.
This was possible on debug c-ares enabled builds when both CURL_MEMDEBUG and CARES_MEMDEBUG environment variables were set. Leading to a file handle leak even when both variables had the same value, and wierd test suite results when different.
This commit is contained in:
parent
bf57e9bb12
commit
1bcbe89802
@ -61,25 +61,29 @@ struct memdebug {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define logfile curl_debuglogfile
|
#define logfile curl_debuglogfile
|
||||||
FILE *curl_debuglogfile;
|
FILE *curl_debuglogfile = NULL;
|
||||||
static bool memlimit; /* enable memory limit */
|
static bool memlimit = FALSE; /* enable memory limit */
|
||||||
static long memsize; /* set number of mallocs allowed */
|
static long memsize = 0; /* set number of mallocs allowed */
|
||||||
|
|
||||||
/* this sets the log file name */
|
/* this sets the log file name */
|
||||||
void curl_memdebug(const char *logname)
|
void curl_memdebug(const char *logname)
|
||||||
{
|
{
|
||||||
if(logname)
|
if (!logfile) {
|
||||||
logfile = fopen(logname, "w");
|
if(logname)
|
||||||
else
|
logfile = fopen(logname, "w");
|
||||||
logfile = stderr;
|
else
|
||||||
|
logfile = stderr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This function sets the number of malloc() calls that should return
|
/* This function sets the number of malloc() calls that should return
|
||||||
successfully! */
|
successfully! */
|
||||||
void curl_memlimit(long limit)
|
void curl_memlimit(long limit)
|
||||||
{
|
{
|
||||||
memlimit = TRUE;
|
if (!memlimit) {
|
||||||
memsize = limit;
|
memlimit = TRUE;
|
||||||
|
memsize = limit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* returns TRUE if this isn't allowed! */
|
/* returns TRUE if this isn't allowed! */
|
||||||
|
Loading…
Reference in New Issue
Block a user