From a4d44250ebda83aac986d94e49004c470a19681e Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 23 Feb 2024 19:51:54 +0100 Subject: [PATCH] BUG/MINOR: ist: only store NUL byte on succeeded alloc The trailing NUL added at the end of istdup() by recent commit de0216758 ("BUG/MINOR: ist: allocate nul byte on istdup") was placed outside of the pointer validity test, rightfully showing null deref warnings. This fix should be backported along with the fix above, to the same versions. --- include/import/ist.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/import/ist.h b/include/import/ist.h index aff799dcb..e4e1425d6 100644 --- a/include/import/ist.h +++ b/include/import/ist.h @@ -944,8 +944,8 @@ static inline struct ist istdup(const struct ist src) if (isttest(dst)) { istcpy(&dst, src, src.len); + dst.ptr[dst.len] = '\0'; } - dst.ptr[dst.len] = '\0'; return dst; }