diff options
author | Joe Tsai <joetsai@digital-static.net> | 2017-06-30 15:44:25 -0700 |
---|---|---|
committer | Joe Tsai <thebrokentoaster@gmail.com> | 2017-06-30 23:42:03 +0000 |
commit | a776087ee3b5780975b51db6a5d66cb7be7c50d4 (patch) | |
tree | f06aff3ac06550b4d5edb7e66ae2f436063fff53 /src/runtime/symtab.go | |
parent | 445652f45361d4935a828f394d7f0322faa6d9ad (diff) | |
download | go-a776087ee3b5780975b51db6a5d66cb7be7c50d4.tar.gz go-a776087ee3b5780975b51db6a5d66cb7be7c50d4.zip |
runtime: allow calling Func.Name on nil pointer
The Func type has allowed calling the Func.Name method on a nil pointer
since Go1.2, where it returned an empty string. A regression caused by
CL/37331 caused this behavior to change. This breaks code that lazily
does runtime.FuncForPC(myPtr).Name() without first checking that myPtr
is actually non-nil.
Fixes #20872
Change-Id: Iae9a2ebabca5e9d1f5a2cdaf2f30e9c6198fec4f
Reviewed-on: https://go-review.googlesource.com/47354
Reviewed-by: Marvin Stenger <marvin.stenger94@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/runtime/symtab.go')
-rw-r--r-- | src/runtime/symtab.go | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/runtime/symtab.go b/src/runtime/symtab.go index 029c2f15af..40add013e4 100644 --- a/src/runtime/symtab.go +++ b/src/runtime/symtab.go @@ -579,6 +579,9 @@ func FuncForPC(pc uintptr) *Func { // Name returns the name of the function. func (f *Func) Name() string { + if f == nil { + return "" + } return funcname(f.funcInfo()) } |