Skip to content

Commit e819787

Browse files
committed
fix nil pointer
1 parent 9f3d3a4 commit e819787

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

pkg/tree/importer/proto/proto_tree_importer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (p *ProtoTreeImporter) GetDeletes() *sdcpb.PathSet {
4242
}
4343

4444
func (p *ProtoTreeImporterElement) GetElements() []importer.ImportConfigAdapterElement {
45-
if len(p.data.Childs) == 0 {
45+
if p.data == nil || len(p.data.Childs) == 0 {
4646
return nil
4747
}
4848
result := []importer.ImportConfigAdapterElement{}

pkg/tree/root_entry.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,15 @@ func (r *RootEntry) TreeExport(owner string, priority int32, deviation bool) (*t
200200

201201
explicitDeletes := r.explicitDeletes.GetByIntentName(owner).ToPathSlice()
202202

203-
if treeExport != nil || len(explicitDeletes) > 0 {
203+
var rootExportEntry *tree_persist.TreeElement
204+
if len(treeExport) != 0 {
205+
rootExportEntry = treeExport[0]
206+
}
207+
208+
if rootExportEntry != nil || len(explicitDeletes) > 0 {
204209
return &tree_persist.Intent{
205210
IntentName: owner,
206-
Root: treeExport[0],
211+
Root: rootExportEntry,
207212
Priority: priority,
208213
Deviation: deviation,
209214
ExplicitDeletes: explicitDeletes,

0 commit comments

Comments
 (0)