container/heap: fix int overflow bug

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7450052
This commit is contained in:
Stefan Nilsson 2013-03-04 10:25:21 -05:00 committed by Russ Cox
parent 9d6e02742c
commit d4a020dec1
1 changed files with 1 additions and 1 deletions

View File

@ -90,7 +90,7 @@ func up(h Interface, j int) {
func down(h Interface, i, n int) {
for {
j1 := 2*i + 1
if j1 >= n {
if j1 >= n || j1 < 0 { // j1 < 0 after int overflow
break
}
j := j1 // left child