From 0b9b41242f69644c43dc29861c9a4ac6d8768423 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 11 Nov 2020 13:32:25 +0100 Subject: Fix unsigned integer underflow This is not undefined behaviour, but sanitizers have a check for it that is useful sometimes, and this makes the return value more predictable anyway. --- src/sord.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/sord.c b/src/sord.c index 0ea4220..52c6e32 100644 --- a/src/sord.c +++ b/src/sord.c @@ -239,7 +239,7 @@ sord_node_compare(const SordNode* a, const SordNode* b) if (a == b || !a || !b) { return 0; // Exact or wildcard match } else if (a->node.type != b->node.type) { - return a->node.type - b->node.type; + return (a->node.type < b->node.type) ? -1 : 1; } int cmp = 0; -- cgit v1.2.1