all: fix more resource leaks found by staticmajor

Updates #5706

Signed-off-by: Emmanuel T Odeke <emmanuel@orijtech.com>
This commit is contained in:
Emmanuel T Odeke
2022-09-27 00:37:27 +02:00
committed by Brad Fitzpatrick
parent 614a24763b
commit 680f8d9793
7 changed files with 45 additions and 3 deletions

View File

@@ -88,11 +88,17 @@ func New(opts Options) (*Auto, error) {
}
// NewNoStart creates a new Auto, but without calling Start on it.
func NewNoStart(opts Options) (*Auto, error) {
func NewNoStart(opts Options) (_ *Auto, err error) {
direct, err := NewDirect(opts)
if err != nil {
return nil, err
}
defer func() {
if err != nil {
direct.Close()
}
}()
if opts.Status == nil {
return nil, errors.New("missing required Options.Status")
}