From 1f895a6ac8aa52d5a5d1b07257b27b62bfca86bb Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 31 Aug 2015 23:05:35 +0200 Subject: fix strdup functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/string/strdup.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/string/strdup.c b/src/string/strdup.c index 27783b9..c65970e 100644 --- a/src/string/strdup.c +++ b/src/string/strdup.c @@ -33,7 +33,7 @@ char* strdup(const char* string) { size_t n = strlen(string) + 1; char* r = malloc(n * sizeof(char)); - return r == NULL ? NULL : memcpy(r, string, n); + return r == NULL ? NULL : memcpy(r, string, n * sizeof(char)); } @@ -55,7 +55,7 @@ char* strndup(const char* string, size_t maxlen) { size_t n = strnlen(string, maxlen) + 1; char* r = malloc(n * sizeof(char)); - return r == NULL ? NULL : memcpy(r, string, n); + return r == NULL ? NULL : memcpy(r, string, n * sizeof(char)); } @@ -73,7 +73,7 @@ char* strndup(const char* string, size_t maxlen) */ void* memdup(const void* segment, size_t size) { - wchar_t* r = malloc(size * sizeof(wchar_t)); + void* r = malloc(size); return r == NULL ? NULL : memcpy(r, segment, size); } -- cgit v1.2.3-70-g09d2