From: Michael Tremer Date: Fri, 27 Nov 2020 15:40:20 +0000 (+0000) Subject: network-list: Exit find operation early when the list is empty X-Git-Tag: 0.9.5~2 X-Git-Url: http://git.ipfire.org/?p=location%2Flibloc.git;a=commitdiff_plain;h=92202e5add0cff31d02f65b3f122ed81fe77a60e network-list: Exit find operation early when the list is empty Signed-off-by: Michael Tremer --- diff --git a/src/network-list.c b/src/network-list.c index e2b20f3..698d3ab 100644 --- a/src/network-list.c +++ b/src/network-list.c @@ -134,6 +134,10 @@ LOC_EXPORT struct loc_network* loc_network_list_get(struct loc_network_list* lis static off_t loc_network_list_find(struct loc_network_list* list, struct loc_network* network, int* found) { + // Insert at the beginning for an empty list + if (loc_network_list_empty(list)) + return 0; + off_t lo = 0; off_t hi = list->size - 1; int result;