aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2004-05-05 13:41:54 +0000
committerDaniel Stenberg <daniel@haxx.se>2004-05-05 13:41:54 +0000
commit32a9554c924febb96c3ff02395333fe7395feb23 (patch)
treeaa292f0d1cffa670ea54a607a14b8043f2f67f00 /lib
parentafc1ed60f7aa36dce4335f7ca287677f0026c422 (diff)
Gisle fixed: don't reference 'mem' if it's NULL.
Diffstat (limited to 'lib')
-rw-r--r--lib/memdebug.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/memdebug.c b/lib/memdebug.c
index 05d0702fe..23f975ef6 100644
--- a/lib/memdebug.c
+++ b/lib/memdebug.c
@@ -129,8 +129,8 @@ void *curl_domalloc(size_t wantedsize, int line, const char *source)
if(logfile && source)
fprintf(logfile, "MEM %s:%d malloc(%zd) = %p\n",
- source, line, wantedsize, mem->mem);
- return mem->mem;
+ source, line, wantedsize, mem ? mem->mem : 0);
+ return (mem ? mem->mem : NULL);
}
void *curl_docalloc(size_t wanted_elements, size_t wanted_size,
@@ -155,8 +155,8 @@ void *curl_docalloc(size_t wanted_elements, size_t wanted_size,
if(logfile && source)
fprintf(logfile, "MEM %s:%d calloc(%u,%u) = %p\n",
- source, line, wanted_elements, wanted_size, mem->mem);
- return mem->mem;
+ source, line, wanted_elements, wanted_size, mem ? mem->mem : 0);
+ return (mem ? mem->mem : NULL);
}
char *curl_dostrdup(const char *str, int line, const char *source)
@@ -172,6 +172,7 @@ char *curl_dostrdup(const char *str, int line, const char *source)
len=strlen(str)+1;
mem=curl_domalloc(len, 0, NULL); /* NULL prevents logging */
+ if (mem)
memcpy(mem, str, len);
if(logfile)