commit: 0467d4c73cc564101ceff32a3b74cc86ea36262c
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 19 11:48:20 2020 +0000
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jan 19 11:48:20 2020 +0000
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=0467d4c7
libq/tree: Coverity 206569 String not terminated
Help Coverity see the string is terminated, effectively turning a more
expensive zalloc into malloc.
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
libq/tree.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libq/tree.c b/libq/tree.c
index 1802d79..94f9665 100644
--- a/libq/tree.c
+++ b/libq/tree.c
@@ -793,10 +793,11 @@ tree_read_file_ebuild(tree_pkg_ctx *pkg_ctx)
goto err;
len = sizeof(*ret) + s.st_size + 1;
- ret = xzalloc(len);
+ ret = xmalloc(len);
p = (char *)ret + sizeof(*ret);
if ((off_t)fread(p, 1, s.st_size, f) != s.st_size)
goto err;
+ p[s.st_size] = '\0';
do {
q = p;