mirror of
https://github.com/flatpak/flatpak.git
synced 2026-10-06 12:59:38 -04:00
dir-utils: Fix signed integer overflow in extension priority comparator
The subtraction-based comparison overflows when priority values are far apart, which is undefined behavior in C.
This commit is contained in:
1 parent
90dd779443
commit
4c78990dd3
1 file changed
+7
-1
@@ -338,7 +338,13 @@ flatpak_extension_compare (gconstpointer _a,
|
||||
const FlatpakExtension *a = _a;
|
||||
const FlatpakExtension *b = _b;
|
||||
|
||||
return b->priority - a->priority;
|
||||
/* Subtraction would overflow for far-apart priorities */
|
||||
if (b->priority > a->priority)
|
||||
return 1;
|
||||
else if (b->priority < a->priority)
|
||||
return -1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static FlatpakExtension *
|
||||
|
||||
Reference in new issue
Block a user