Skip to content

Commit 8addc50

Browse files
authored
fix: guard against nil os.Args and exit vs panic (#272)
Signed-off-by: Chris Gianelloni <[email protected]>
1 parent d60b964 commit 8addc50

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

cmd/adder/main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ func slogPrintf(format string, v ...any) {
4444
func main() {
4545
cfg := config.GetConfig()
4646

47+
if os.Args == nil {
48+
fmt.Println("Failed to detect arguments, aborting")
49+
os.Exit(1)
50+
}
51+
4752
if err := cfg.ParseCmdlineArgs(programName, os.Args[1:]); err != nil {
4853
fmt.Printf("Failed to parse commandline: %s\n", err)
4954
os.Exit(1)

0 commit comments

Comments
 (0)