Skip to content

Commit e693f31

Browse files
committed
fix(backup): null pointer
1 parent c97107a commit e693f31

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

services/project/backup.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -305,14 +305,15 @@ func (b *BackupDB) format() (*BackupFormat, error) {
305305
Inventory, _ = findNameByID[db.Inventory](*o.InventoryID, b.inventories)
306306
}
307307

308-
surveyVars := make([]db.SurveyVar, 0)
309-
err := json.Unmarshal([]byte(*o.SurveyVarsJSON), &surveyVars)
310-
if err != nil {
311-
return nil, err
308+
if o.SurveyVarsJSON != nil {
309+
surveyVars := make([]db.SurveyVar, 0)
310+
err := json.Unmarshal([]byte(*o.SurveyVarsJSON), &surveyVars)
311+
if err != nil {
312+
return nil, err
313+
}
314+
o.SurveyVars = surveyVars
312315
}
313316

314-
o.SurveyVars = surveyVars
315-
316317
templates[i] = BackupTemplate{
317318
Template: o,
318319
View: View,

0 commit comments

Comments
 (0)