commit:     d742c0ca62307ac1b8360acbf8dc19c3780f60e4
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 26 18:18:34 2026 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Jan 26 18:18:34 2026 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=d742c0ca

libq/tree: fix NULL-ptr deref in tree_pkg_ebuild_read, CID 557227

When we reached the end of the file, p == NULL, which means the
while-loop will try to dereference that (and fail).

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 4f88a53c..a01499b5 100644
--- a/libq/tree.c
+++ b/libq/tree.c
@@ -932,7 +932,8 @@ static bool tree_pkg_ebuild_read
         (p = strchr(p, '\n')) != NULL)
       p++;
   }
-  while (*p != '\0');
+  while (p != NULL &&
+         *p != '\0');
 
   return true;
 }

Reply via email to