diff options
Diffstat (limited to 'accel-pppd/memdebug.c')
-rw-r--r-- | accel-pppd/memdebug.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/accel-pppd/memdebug.c b/accel-pppd/memdebug.c index 67c8498..8c3c494 100644 --- a/accel-pppd/memdebug.c +++ b/accel-pppd/memdebug.c @@ -142,9 +142,13 @@ void __export *md_realloc(void *ptr, size_t size, const char *fname, int line) char __export *md_strdup(const char *ptr, const char *fname, int line) { - struct mem_t *mem = _md_malloc(strlen(ptr) + 1, fname, line); - memcpy(mem->data, ptr, strlen(ptr) + 1); - return mem->data; + size_t len = strlen(ptr); + char *str = md_malloc(len + 1, fname, line); + + if (str) + memcpy(str, ptr, len + 1); + + return str; } char __export *md_strndup(const char *ptr, size_t n, const char *fname, int line) |