1
2
3
4
5
6
7
8
9
10
11 package main
12
13 import "runtime"
14
15 func bad(b bool) uintptr {
16 var p **int
17 var x1 uintptr
18 x1 = 1
19 if b {
20 var x [11]*int
21 p = &x[0]
22 }
23 if b {
24 var x [1]*int
25 p = &x[0]
26 }
27 runtime.GC()
28 if p != nil {
29 x1 = uintptr(**p)
30 }
31 return x1
32 }
33
34 func poison() uintptr {
35 runtime.GC()
36 var x [20]uintptr
37 var s uintptr
38 for i := range x {
39 x[i] = uintptr(i+1)
40 s += x[i]
41 }
42 return s
43 }
44
45 func main() {
46 poison()
47 bad(false)
48 }
49
View as plain text