From ca0e1d32792f03bdccbc14becb477595f5ee34a2 Mon Sep 17 00:00:00 2001 From: Michal Gorecki Date: Mon, 11 Mar 2024 14:40:41 +0100 Subject: [PATCH] newt: Fix crash when package is missing When package from build was missing the b.Build() was returning an error before AppBuilder was created. It was resulting in dereferencing null pointer in such situation. --- newt/cli/build_cmds.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/newt/cli/build_cmds.go b/newt/cli/build_cmds.go index 309b43455..ce1611536 100644 --- a/newt/cli/build_cmds.go +++ b/newt/cli/build_cmds.go @@ -161,10 +161,12 @@ func buildRunCmd(cmd *cobra.Command, args []string, printShellCmds bool, execute } if err := b.Build(); err != nil { - if b.AppBuilder.GetModifiedRepos() != nil { - util.ErrorMessage(util.VERBOSITY_DEFAULT, - "Warning: Following external repos are modified or missing, which might be causing build errors:\n%v\n", - b.AppBuilder.GetModifiedRepos()) + if b.AppBuilder != nil { + if b.AppBuilder.GetModifiedRepos() != nil { + util.ErrorMessage(util.VERBOSITY_DEFAULT, + "Warning: Following external repos are modified or missing, which might be causing build errors:\n%v\n", + b.AppBuilder.GetModifiedRepos()) + } } NewtUsage(nil, err) }