~emersion/soju

3b1cf73165afbc61e8eec93afcdffde7bffdba98 — Moritz Poldrack 30 days ago c1fc2f1
Fix crash on start when file-upload is disabled

When started without specifying a fileupload backend, soju crashes
because of a nil-pointer deref.

	panic: runtime error: invalid memory address or nil pointer dereference
	[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x9484bd]

	goroutine 1 [running]:
	main.loadConfig()
		git.sr.ht/~emersion/soju/cmd/soju/main.go:94 +0x51d
	main.main()
		git.sr.ht/~emersion/soju/cmd/soju/main.go:127 +0x165
	panic: runtime error: invalid memory address or nil pointer dereference

Add a guardclause preventing that crash.

Signed-off-by: Moritz Poldrack <git@moritz.sh>
1 files changed, 1 insertions(+), 1 deletions(-)

M cmd/soju/main.go
M cmd/soju/main.go => cmd/soju/main.go +1 -1
@@ 91,7 91,7 @@ func loadConfig() (*config.Server, *soju.Config, error) {
	}

	var fileUploader fileupload.Uploader
	if raw.FileUpload.Driver != "" {
	if raw.FileUpload != nil {
		fileUploader, err = fileupload.New(raw.FileUpload.Driver, raw.FileUpload.Source)
		if err != nil {
			return nil, nil, fmt.Errorf("failed to create file uploader: %v", err)