[pacman-dev] [PATCH 1/4] check dep versions before calling strcmp

Andrew Gregory andrew.gregory.8 at gmail.com
Thu Jul 16 23:05:31 UTC 2015


Fixes a segfault when trying to remove an assumeinstalled
option without a version.

Signed-off-by: Andrew Gregory <andrew.gregory.8 at gmail.com>
---
 lib/libalpm/handle.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index 4915d0b..1be2484 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -606,10 +606,21 @@ static int assumeinstalled_cmp(const void *d1, const void *d2)
 	const alpm_depend_t *dep1 = d1;
 	const alpm_depend_t *dep2 = d2;
 
-	if(strcmp(dep1->name, dep2->name) == 0 && strcmp(dep1->version, dep2->version) == 0) {
+	if(dep1->name_hash != dep2->name_hash
+			|| strcmp(dep1->name, dep2->name) != 0) {
+		return -1;
+	}
+
+	if(dep1->version && dep2->version
+			&& strcmp(dep1->version, dep2->version) == 0) {
 		return 0;
 	}
 
+	if(dep1->version == NULL && dep2->version == NULL) {
+		return 0;
+	}
+
+
 	return -1;
 }
 
-- 
2.4.6


More information about the pacman-dev mailing list