From fef20d10a273281e95fde5eb190afce425979269 Mon Sep 17 00:00:00 2001 From: None Date: Thu, 5 Nov 2020 22:33:33 +0800 Subject: [PATCH 1/5] Update gtimer_timer.go bugfix: avoid overflow --- os/gtimer/gtimer_timer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/os/gtimer/gtimer_timer.go b/os/gtimer/gtimer_timer.go index f03a5118c..733c09d62 100644 --- a/os/gtimer/gtimer_timer.go +++ b/os/gtimer/gtimer_timer.go @@ -233,7 +233,7 @@ func (t *Timer) binSearchIndex(n int64) (index int, result int) { mid := 0 cmp := -2 for min <= max { - mid = int((min + max) / 2) + mid = min + int((max-min)/2) switch { case t.wheels[mid].intervalMs == n: cmp = 0 From ed4a70deffec0c4fbe53742bbd47d84708add851 Mon Sep 17 00:00:00 2001 From: None Date: Thu, 5 Nov 2020 22:37:36 +0800 Subject: [PATCH 2/5] Update garray_sorted_any.go bugfix: avoid overflow --- container/garray/garray_sorted_any.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/container/garray/garray_sorted_any.go b/container/garray/garray_sorted_any.go index d056464d7..030840f11 100644 --- a/container/garray/garray_sorted_any.go +++ b/container/garray/garray_sorted_any.go @@ -446,7 +446,7 @@ func (a *SortedArray) binSearch(value interface{}, lock bool) (index int, result mid := 0 cmp := -2 for min <= max { - mid = (min + max) / 2 + mid = min + int((max-min)/2) cmp = a.getComparator()(value, a.array[mid]) switch { case cmp < 0: From 784abf2a306d8ecfdd539af57d188926905cd9b0 Mon Sep 17 00:00:00 2001 From: None Date: Thu, 5 Nov 2020 22:41:43 +0800 Subject: [PATCH 3/5] Update garray_sorted_int.go bugfix: avoid overflow --- container/garray/garray_sorted_int.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/container/garray/garray_sorted_int.go b/container/garray/garray_sorted_int.go index 28d3e97f9..3153c9cd5 100644 --- a/container/garray/garray_sorted_int.go +++ b/container/garray/garray_sorted_int.go @@ -443,7 +443,7 @@ func (a *SortedIntArray) binSearch(value int, lock bool) (index int, result int) mid := 0 cmp := -2 for min <= max { - mid = (min + max) / 2 + mid = min + int((max-min)/2) cmp = a.getComparator()(value, a.array[mid]) switch { case cmp < 0: From ea9e8055a4ba7182d15ae1a49772c899f59d1cf8 Mon Sep 17 00:00:00 2001 From: None Date: Thu, 5 Nov 2020 22:42:15 +0800 Subject: [PATCH 4/5] Update garray_sorted_str.go bugfix: avoid overflow --- container/garray/garray_sorted_str.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/container/garray/garray_sorted_str.go b/container/garray/garray_sorted_str.go index 649732347..9e23da894 100644 --- a/container/garray/garray_sorted_str.go +++ b/container/garray/garray_sorted_str.go @@ -445,7 +445,7 @@ func (a *SortedStrArray) binSearch(value string, lock bool) (index int, result i mid := 0 cmp := -2 for min <= max { - mid = (min + max) / 2 + mid = min + int((max-min)/2) cmp = a.getComparator()(value, a.array[mid]) switch { case cmp < 0: From 1072ea3fb07a46fa72ed4d66dcbb6c160310bd01 Mon Sep 17 00:00:00 2001 From: None Date: Thu, 5 Nov 2020 22:44:09 +0800 Subject: [PATCH 5/5] Update gtree_btree.go bugfix: avoid overflow --- container/gtree/gtree_btree.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/container/gtree/gtree_btree.go b/container/gtree/gtree_btree.go index 926898add..febc8ec9a 100644 --- a/container/gtree/gtree_btree.go +++ b/container/gtree/gtree_btree.go @@ -620,7 +620,7 @@ func (tree *BTree) middle() int { func (tree *BTree) search(node *BTreeNode, key interface{}) (index int, found bool) { low, mid, high := 0, 0, len(node.Entries)-1 for low <= high { - mid = (high + low) / 2 + mid = low + int((high-low)/2) compare := tree.getComparator()(key, node.Entries[mid].Key) switch { case compare > 0: