From 0aad9492f1071e7dc832510a503d7195deed1aa3 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 19 Oct 2021 15:54:45 +0100 Subject: [PATCH] [Minor] Close fd --- src/libstat/backends/cdb_backend.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libstat/backends/cdb_backend.cxx b/src/libstat/backends/cdb_backend.cxx index 5b5b42cdf..7715e9b6b 100644 --- a/src/libstat/backends/cdb_backend.cxx +++ b/src/libstat/backends/cdb_backend.cxx @@ -307,11 +307,15 @@ open_cdb(struct rspamd_statfile *st) -> tl::expected cdbp = cdb_shared_storage::new_cdb(); if (cdb_init(cdbp.get(), fd) == -1) { + close(fd); + return tl::make_unexpected(fmt::format("cannot init cdb in {}: {}", path, strerror(errno))); } cdbp = cdb_shared_storage.push_cdb(path, cdbp); + + close(fd); } else { cdbp = cached_cdb_maybe.value(); -- 2.39.5