From d30183cbf77bce87ed5d96c1021e9521ac10c015 Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Sun, 5 Feb 2023 14:16:08 +1000 Subject: Jim_StrDupLen: minor optimisation No need to copy a char that will be overwritten in the next line. Signed-off-by: Steve Bennett --- jim.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jim.c b/jim.c index fba93cb..8806ec4 100644 --- a/jim.c +++ b/jim.c @@ -684,8 +684,8 @@ char *Jim_StrDupLen(const char *s, int l) { char *copy = Jim_Alloc(l + 1); - memcpy(copy, s, l + 1); - copy[l] = 0; /* Just to be sure, original could be substring */ + memcpy(copy, s, l); + copy[l] = 0; /* NULL terminate */ return copy; } -- cgit v1.1