1
0
mirror of https://github.com/golang/go synced 2024-09-24 01:10:14 -06:00

Don't crash in Sym.ReceiverName for symbols like "x.x"

R=rsc
APPROVED=rsc
DELTA=2  (0 added, 0 deleted, 2 changed)
OCL=34404
CL=34406
This commit is contained in:
Austin Clements 2009-09-04 16:12:50 -07:00
parent c702bdd828
commit eabcb10a32
2 changed files with 2 additions and 2 deletions

View File

@ -52,7 +52,7 @@ func (s *Sym) PackageName() string {
func (s *Sym) ReceiverName() string {
l := strings.Index(s.Name, ".");
r := strings.LastIndex(s.Name, ".");
if l == -1 || r == -1 {
if l == -1 || r == -1 || l == r {
return "";
}
return s.Name[l+1:r];

View File

@ -63,7 +63,7 @@ func (c *CommonSym) PackageName() string {
func (c *CommonSym) ReceiverName() string {
l := strings.Index(c.Name, "·");
r := strings.LastIndex(c.Name, "·");
if l == -1 || r == -1 {
if l == -1 || r == -1 || l == r {
return "";
}
return c.Name[l+len("·"):r];