From: W.C.A. Wijngaards Date: Fri, 2 Aug 2024 06:58:22 +0000 (+0200) Subject: - Fix testbound for alloc stats strdup in util/alloc.c. X-Git-Tag: release-1.21.0rc1~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6106528a500276a86b264ba3be700eb133735a5e;p=thirdparty%2Funbound.git - Fix testbound for alloc stats strdup in util/alloc.c. --- 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; }