]> git.ipfire.org Git - thirdparty/kmod.git/commit
strbuf: Do not append '\0' if not needed
authorLucas De Marchi <lucas.de.marchi@gmail.com>
Tue, 12 Nov 2024 19:43:20 +0000 (13:43 -0600)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Sun, 17 Nov 2024 21:35:13 +0000 (15:35 -0600)
commitcc2ba0b74a0b86b82181fbb1fa75d3ab953383cd
tree8d8da8d13240ff92144dc78228aad49fd3d75520
parent952bf223e050fdd576eb573dd099875fbb3518c2
strbuf: Do not append '\0' if not needed

Unconditionally appending '\0' is not a big problem, but that does
trigger the buffer to potentially be re-allocated. Avoid that by
checking the last char is not already NUL.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/239
shared/strbuf.c