mirror of
https://github.com/golang/go
synced 2024-11-11 22:20:22 -07: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:
parent
c702bdd828
commit
eabcb10a32
@ -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];
|
||||
|
@ -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];
|
||||
|
Loading…
Reference in New Issue
Block a user