search: fix panic when claim and permanode have no attributes.

fixes #881

Change-Id: Ifdea54a56bf879ca418763617acf7bd2b9159dad
This commit is contained in:
Stephen Searles 2016-11-19 00:58:13 -08:00
parent 3b815de5a6
commit bbecbc47cd
2 changed files with 12 additions and 1 deletions

View File

@ -149,5 +149,10 @@ func (pa permAttr) get(attr string) string {
}
return ""
}
return claimsIntfAttrValue(pa.claims, attr, pa.at, pa.signerFilter)
if pa.claims != nil {
return claimsIntfAttrValue(pa.claims, attr, pa.at, pa.signerFilter)
}
return ""
}

View File

@ -77,7 +77,13 @@ type claimPtrSlice []*camtypes.Claim
func (s claimPtrSlice) Len() int { return len(s) }
func (s claimPtrSlice) Claim(i int) *camtypes.Claim { return s[i] }
// claimsIntfAttrValue finds the value of an attribute in a list of claims
// or empty string if not found. claims must be non-nil.
func claimsIntfAttrValue(claims claimsIntf, attr string, at time.Time, signerFilter blob.Ref) string {
if claims == nil {
panic("nil claims argument in claimsIntfAttrValue")
}
if at.IsZero() {
at = time.Now()
}