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.
This commit is contained in:
Willy Tarreau 2024-02-23 19:51:54 +01:00
parent 3f771f5118
commit a4d44250eb

View File

@ -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;
}