From ba247d060693eb13eb791cfaa6f1a80b155f7644 Mon Sep 17 00:00:00 2001 From: Thomas von Dein Date: Mon, 27 May 2024 14:04:40 +0200 Subject: [PATCH] fix crash --- config.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/config.go b/config.go index de89d11..91fb021 100644 --- a/config.go +++ b/config.go @@ -8,6 +8,7 @@ import ( "strconv" "strings" + "github.com/alecthomas/repr" "github.com/spf13/pflag" "github.com/tlinden/golsky/rle" ) @@ -66,8 +67,14 @@ func (config *Config) ParseGeom(geom string) error { // fit into window config.ScreenWidth = width - (width % config.Width) config.ScreenHeight = height - (height % config.Height) + + if config.ScreenWidth == 0 || config.ScreenHeight == 0 { + return errors.New("the number of requested cells don't fit into the requested window size") + } + config.Cellsize = config.ScreenWidth / config.Width + repr.Println(config) return nil }