]> Cypherpunks repositories - gostls13.git/commitdiff
container/heap: fix int overflow bug
authorStefan Nilsson <snilsson@nada.kth.se>
Mon, 4 Mar 2013 15:25:21 +0000 (10:25 -0500)
committerRuss Cox <rsc@golang.org>
Mon, 4 Mar 2013 15:25:21 +0000 (10:25 -0500)
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7450052

src/pkg/container/heap/heap.go

index 7fd41f785f10600592a3420102b7a80a661a0105..c37e50e3c4058a5f388546292eb8598a04c6abd2 100644 (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