Skip to content

Commit

Permalink
libq/atom: fix atom comparison bug
Browse files Browse the repository at this point in the history
qlop SEGFAULTed when predict on a package without category was called

Closes: #24
Signed-off-by: Pavel Kalugin <pavel@pavelthebest.me>
Signed-off-by: Fabian Groffen <grobian@gentoo.org>
  • Loading branch information
p4vook authored and grobian committed Jan 27, 2024
1 parent e023e57 commit e05b6ba
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion libq/atom.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e05b6ba

Please sign in to comment.