From: Ramakrishnan Muthukrishnan Date: Fri, 10 Nov 2023 02:00:09 +0000 (+0530) Subject: fixes an overflow (for very large number of elements) in binary search X-Git-Url: https://git.rkrishnan.org/Site/Content/Exhibitors/nxhtml.html?a=commitdiff_plain;h=3d637ada5d1f4c18123e5f80014b7a3f27b40fd1;p=pihpsdr.git fixes an overflow (for very large number of elements) in binary search --- diff --git a/rigctl.c b/rigctl.c index b1adbdc..a38d4a5 100644 --- a/rigctl.c +++ b/rigctl.c @@ -4539,7 +4539,8 @@ bool search(cat_command *commands, char cmd[2], int *index) { while (l <= r) { // go to the middle of the array[r:l] // and pick out the middle element. - int m = (l + r)/2; + // int m = (l + r)/2; + int m = l + (r - l)/2; // compare the command name in the middle element // with the one we are looking for.