From 7efce91092a090c738ffae0f7b2cb47cc3391b03 Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 8 Nov 2024 07:22:15 +0800 Subject: [PATCH] Add nil checks for Action and Bind in translate function to prevent potential nil pointer dereferences --- widgets/form/handler.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/widgets/form/handler.go b/widgets/form/handler.go index 148ad55d..d582c1f4 100644 --- a/widgets/form/handler.go +++ b/widgets/form/handler.go @@ -106,16 +106,16 @@ func (dsl *DSL) translate(name string, process *gouProcess.Process, data interfa } widgets := []string{} - if dsl.Action.Bind.Model != "" { + if dsl.Action != nil && dsl.Action.Bind != nil && dsl.Action.Bind.Model != "" { m := model.Select(dsl.Action.Bind.Model) widgets = append(widgets, fmt.Sprintf("model.%s", m.ID)) } - if dsl.Action.Bind.Table != "" { + if dsl.Action != nil && dsl.Action.Bind != nil && dsl.Action.Bind.Table != "" { widgets = append(widgets, fmt.Sprintf("table.%s", dsl.Action.Bind.Table)) } - if dsl.Action.Bind.Form != "" { + if dsl.Action != nil && dsl.Action.Bind != nil && dsl.Action.Bind.Form != "" { widgets = append(widgets, fmt.Sprintf("form.%s", dsl.Action.Bind.Form)) }