mirror of
https://github.com/golang/go
synced 2024-11-24 08:00:12 -07:00
b19ec6842d
Indirect function and method calls should leak everything, but they didn't. This fix had no particular effect on the cost of running the compiler on html/template/*.go and added a single new "escape" to the standard library: syscall/syscall_unix.go:85: &b[0] escapes to heap in if errno := m.munmap(uintptr(unsafe.Pointer(&b[0])), uintptr(len(b))); errno != nil { Added specific escape testing to escape_calls.go (and verified that it fails without this patch) I also did a little code cleanup around the changes in esc.c. Fixes #10925 Change-Id: I9984b701621ad4c49caed35b01e359295c210033 Reviewed-on: https://go-review.googlesource.com/10295 Reviewed-by: Russ Cox <rsc@golang.org>
24 lines
588 B
Go
24 lines
588 B
Go
// run
|
|
|
|
// Copyright 2015 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package main
|
|
|
|
import "fmt"
|
|
|
|
func prototype(xyz []string) {}
|
|
func main() {
|
|
var got [][]string
|
|
f := prototype
|
|
f = func(ss []string) { got = append(got, ss) }
|
|
for _, s := range []string{"one", "two", "three"} {
|
|
f([]string{s})
|
|
}
|
|
if got[0][0] != "one" || got[1][0] != "two" || got[2][0] != "three" {
|
|
// Bug's wrong output was [[three] [three] [three]]
|
|
fmt.Println("Expected [[one] [two] [three]], got", got)
|
|
}
|
|
}
|