From c9cbbb4054b85947f1ddc52f1ae0b3e18794c784 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Wed, 4 Oct 2017 20:13:56 -0300 Subject: [PATCH] lib: fix bug in if_cmp_name_func() If the p1 and p2 arguments pointed to identical strings ending with a non-numeric character (e.g. "lo"), this function would return -1 instead of 0 as one would expect. This inconsistency didn't matter for sorted linked-lists but for red-black trees it's a major source of problems. Signed-off-by: Renato Westphal --- lib/if.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/if.c b/lib/if.c index 612cc2081e..36fd509bcb 100644 --- a/lib/if.c +++ b/lib/if.c @@ -91,6 +91,8 @@ int if_cmp_name_func(char *p1, char *p2) p1 += l1; p2 += l1; + if (!*p1 && !*p2) + return 0; if (!*p1) return -1; if (!*p2) -- 2.39.5