commit:     860ace7e297f4f79b1cd52c7bbee48a5a1ed78ce
Author:     Joakim Tjernlund <joakim.tjernlund <AT> infinera <DOT> com>
AuthorDate: Wed Jun 16 14:43:11 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jun 16 19:19:43 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=860ace7e

qmerge: Protect against NULL ptr

hash will be NULL if file does not exist.

Signed-off-by: Joakim Tjernlund <joakim.tjernlund <AT> infinera.com>
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/qmerge.c b/qmerge.c
index 2e8730e..7b42956 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1513,7 +1513,9 @@ pkg_unmerge(tree_pkg_ctx *pkg_ctx, set *keep,
                                        /* If the file wasn't modified, unmerge 
it */
                                        char *hash = hash_file_at(portroot_fd,
                                                        e->name + 1, HASH_MD5);
-                                       protected = strcmp(e->digest, (const 
char *)hash);
+                                       protected = 0;
+                                       if (hash)
+                                               protected = strcmp(e->digest, 
(const char *)hash);
                                }
                                break;
 

Reply via email to