commit 0aad949: [Minor] Close fd

Vsevolod Stakhov vsevolod at highsecure.ru
Tue Oct 19 19:56:04 UTC 2021


Author: Vsevolod Stakhov
Date: 2021-10-19 15:54:45 +0100
URL: https://github.com/rspamd/rspamd/commit/0aad9492f1071e7dc832510a503d7195deed1aa3

[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<ro_backend, std::string>
 		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();


More information about the Commits mailing list