From 6106528a500276a86b264ba3be700eb133735a5e Mon Sep 17 00:00:00 2001 From: "W.C.A. Wijngaards" Date: Fri, 2 Aug 2024 08:58:22 +0200 Subject: [PATCH] - Fix testbound for alloc stats strdup in util/alloc.c. --- testcode/testbound.c | 17 ----------------- util/alloc.c | 3 +-- 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/testcode/testbound.c b/testcode/testbound.c index f023860e0..123fe0d4e 100644 --- a/testcode/testbound.c +++ b/testcode/testbound.c @@ -72,23 +72,6 @@ int daemon_main(int argc, char* argv[]); /** config files (removed at exit) */ static struct config_strlist* cfgfiles = NULL; -#ifdef UNBOUND_ALLOC_STATS -# define strdup(s) unbound_stat_strdup_log(s, __FILE__, __LINE__, __func__) -char* unbound_stat_strdup_log(char* s, const char* file, int line, - const char* func); -char* unbound_stat_strdup_log(char* s, const char* file, int line, - const char* func) { - char* result; - size_t len; - if(!s) return NULL; - len = strlen(s); - log_info("%s:%d %s strdup(%u)", file, line, func, (unsigned)len+1); - result = unbound_stat_malloc(len+1); - memmove(result, s, len+1); - return result; -} -#endif /* UNBOUND_ALLOC_STATS */ - /** give commandline usage for testbound. */ static void testbound_usage(void) diff --git a/util/alloc.c b/util/alloc.c index d00976b7f..a6c911803 100644 --- a/util/alloc.c +++ b/util/alloc.c @@ -475,8 +475,7 @@ char *unbound_stat_strdup(const char* s) len = strlen(s); res = unbound_stat_malloc(len+1); if(!res) return NULL; - memmove(res, s, len); - res[len]=0; + memmove(res, s, len+1); return res; } -- 2.47.3