Skip to content

Commit 0abd3fc

Browse files
committed
fix(cmd): prevent nil pointer dereference in DetectChanges method
AI-Generated: true AI-Model: claude-3.5-sonnet Signed-off-by: AtomicFS <vojtech.vesely@9elements.com>
1 parent 95666bd commit 0abd3fc

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

cmd/firmware-action/recipes/detect_changes.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,15 @@ func (c *ChangeConfig) DetectChanges(target string) bool {
7979
// proving to be far too much work. Instead we save the whole configuration file (for each module
8080
// separately) and only compare the relevant modules between these two configurations
8181

82+
// Check if current config is nil
83+
if c.Config == nil {
84+
slog.Warn("Current configuration is nil, assuming no changes are needed",
85+
slog.String("suggestion", logging.ThisShouldNotHappenMessage),
86+
)
87+
c.ChangesDetected = false
88+
return false
89+
}
90+
8291
err := filesystem.CheckFileExists(c.ResultFile)
8392
if errors.Is(err, os.ErrExist) {
8493
oldConfig, err := ReadConfig(c.ResultFile)

0 commit comments

Comments
 (0)