Commit d4a020de authored by Stefan Nilsson's avatar Stefan Nilsson Committed by Russ Cox

container/heap: fix int overflow bug

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7450052
parent 9d6e0274
...@@ -90,7 +90,7 @@ func up(h Interface, j int) { ...@@ -90,7 +90,7 @@ func up(h Interface, j int) {
func down(h Interface, i, n int) { func down(h Interface, i, n int) {
for { for {
j1 := 2*i + 1 j1 := 2*i + 1
if j1 >= n { if j1 >= n || j1 < 0 { // j1 < 0 after int overflow
break break
} }
j := j1 // left child j := j1 // left child
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment