Skip to content

Commit

Permalink
fix(serving): avoid returning a nil node in map (#4487)
Browse files Browse the repository at this point in the history
  • Loading branch information
schroederc committed Apr 22, 2020
1 parent 5240cac commit 4e30366
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions kythe/go/serving/xrefs/xrefs.go
Original file line number Diff line number Diff line change
Expand Up @@ -898,21 +898,23 @@ func d2d(d *srvpb.Document, patterns []*regexp.Regexp, nodes map[string]*cpb.Nod
continue
}

nodes[node.Ticket] = nodeToInfo(patterns, node)
n := nodeToInfo(patterns, node)
if def := node.DefinitionLocation; def != nil {
n := nodes[node.Ticket]
if n == nil {
// Add an empty NodeInfo to attach definition location even if no facts
// are requested.
n = &cpb.NodeInfo{}
nodes[node.Ticket] = n
}

n.Definition = def.Ticket
if _, ok := defs[def.Ticket]; !ok {
defs[def.Ticket] = a2a(def, false).Anchor
}
}

if n != nil {
nodes[node.Ticket] = n
}
}

return &xpb.DocumentationReply_Document{
Expand Down

0 comments on commit 4e30366

Please sign in to comment.