From 9df5e1f764bfe2640e431c68992eb5149dafcbb8 Mon Sep 17 00:00:00 2001 From: Kilian von Pflugk Date: Thu, 1 Aug 2024 19:46:23 +0200 Subject: [PATCH] ensure impl is not nil --- jdownloader/device.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/jdownloader/device.go b/jdownloader/device.go index bc1c73e..5462dbf 100644 --- a/jdownloader/device.go +++ b/jdownloader/device.go @@ -20,9 +20,10 @@ import ( "encoding/base64" "encoding/json" "fmt" - "go.uber.org/zap" "net/http" "net/url" + + "go.uber.org/zap" ) type DirectConnectionPort struct { @@ -112,6 +113,11 @@ func serializeParams(marshal bool, params ...interface{}) ([]interface{}, error) } func (d *jDevice) doDevice(action string, marshal bool, params ...interface{}) (_ *DataResponse, err error) { + // Ensure impl is not nil + if d.impl == nil { + return nil, fmt.Errorf("device implementation is not initialized") + } + err = d.impl.reconnectIfNecessary() if err != nil { return nil, err