aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Kalugin <pavel@pavelthebest.me>2023-12-12 22:32:35 +0300
committerFabian Groffen <grobian@gentoo.org>2024-01-27 14:27:30 +0100
commite05b6baf296397bc2a10dad728f2840ab242b833 (patch)
tree6ff71fc432ffd1629469401848f06138ed6565d9
parentqmerge: sloppily circumvent Coverity 125893 (diff)
downloadportage-utils-e05b6baf296397bc2a10dad728f2840ab242b833.tar.gz
portage-utils-e05b6baf296397bc2a10dad728f2840ab242b833.tar.bz2
portage-utils-e05b6baf296397bc2a10dad728f2840ab242b833.zip
libq/atom: fix atom comparison bug
qlop SEGFAULTed when predict on a package without category was called Closes: https://github.com/gentoo/portage-utils/pull/24 Signed-off-by: Pavel Kalugin <pavel@pavelthebest.me> Signed-off-by: Fabian Groffen <grobian@gentoo.org>
-rw-r--r--libq/atom.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/libq/atom.c b/libq/atom.c
index 31299f1..b1a150a 100644
--- a/libq/atom.c
+++ b/libq/atom.c
@@ -1252,7 +1252,15 @@ atom_compar_cb(const void *l, const void *r)
default:
{
int ret;
- ret = strcmp(al->CATEGORY, ar->CATEGORY);
+ if (!al->CATEGORY && !ar->CATEGORY) {
+ ret = 0;
+ } else if (!al->CATEGORY) {
+ ret = -1;
+ } else if (!ar->CATEGORY) {
+ ret = 1;
+ } else {
+ ret = strcmp(al->CATEGORY, ar->CATEGORY);
+ }
if (ret == 0)
ret = strcasecmp(al->PN, ar->PN);
return ret;