Skip to content

Commit

Permalink
Add another panic safeguard
Browse files Browse the repository at this point in the history
  • Loading branch information
bandreghetti committed Nov 13, 2020
1 parent 04dcad1 commit 3e6e604
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions assets/references.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ func (a Asset) Refs(stub shim.ChaincodeStubInterface) ([]Key, errors.ICCError) {
return nil, errors.NewCCError("sub-asset reference badly formatted", 400)
}

if subAssetRefMap == nil {
return nil, errors.NewCCError(fmt.Sprintf("sub-asset reference '%s' cannot be nil", subAsset.Tag), 400)
}

subAssetTypeName, ok := subAssetRefMap["@assetType"]
if ok && subAssetTypeName != subAssetDataType {
return nil, errors.NewCCError("sub-asset reference of wrong asset type", 400)
Expand Down
2 changes: 1 addition & 1 deletion assets/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (a *Asset) Update(stub shim.ChaincodeStubInterface, update map[string]inter

// Check if property is included in the update map
propInterface, propIncluded := update[prop.Tag]
if !propIncluded {
if !propIncluded || propInterface == nil {
continue
}

Expand Down

0 comments on commit 3e6e604

Please sign in to comment.