From 47f54b5650bb56d0010b3a6542769a4c15bfdba7 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 20 Jul 2020 22:43:48 +0200 Subject: [PATCH] input/smbclient: close handle on stat error --- src/input/plugins/SmbclientInputPlugin.cxx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/input/plugins/SmbclientInputPlugin.cxx b/src/input/plugins/SmbclientInputPlugin.cxx index 6799e87ed..bc23a4c23 100644 --- a/src/input/plugins/SmbclientInputPlugin.cxx +++ b/src/input/plugins/SmbclientInputPlugin.cxx @@ -90,8 +90,11 @@ input_smbclient_open(const char *uri, throw MakeErrno("smbc_open() failed"); struct stat st; - if (ctx.Stat(handle, st) < 0) - throw MakeErrno("smbc_fstat() failed"); + if (ctx.Stat(handle, st) < 0) { + const int e = errno; + ctx.Close(handle); + throw MakeErrno(e, "smbc_fstat() failed"); + } return std::make_unique (std::make_unique(uri, mutex,