1
0
mirror of https://github.com/golang/go synced 2024-11-22 16:34:47 -07:00

cmd/link: make Loader.SymName not crash

Even if not presented with a valid symbol, recover gracefully,
so that debug prints do not crash.

Change-Id: I06bbe4bec5f90b79b4830e772a7fc3d7c919df1b
Reviewed-on: https://go-review.googlesource.com/c/go/+/312036
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
Russ Cox 2021-04-14 12:44:04 -04:00
parent 199575a119
commit 59ceb985c7

View File

@ -771,6 +771,9 @@ func (l *Loader) SymName(i Sym) string {
return pp.name
}
r, li := l.toLocal(i)
if r == nil {
return "?"
}
name := r.Sym(li).Name(r.Reader)
if !r.NeedNameExpansion() {
return name