From 8ae7998aabae4f208d77afcb930dafabade1b28d Mon Sep 17 00:00:00 2001 From: costan Date: Tue, 3 Oct 2017 13:41:46 -0700 Subject: [PATCH] Fix FD leak in POSIX Env. Deleting a PosixWritableFile without calling Close() leaks the file descriptor. While the API description in include/leveldb/env.h does not specify whether the caller is responsible for Close()ing the file before deleting it, all other Env file implementations do release underlying resources when destroyed, even if Close() is not called. The leak shows up when running db_tests on Mac Travis, or on a vanilla MacOS install. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=170906843 --- util/env_posix.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/env_posix.cc b/util/env_posix.cc index 8d84ac7..8327978 100644 --- a/util/env_posix.cc +++ b/util/env_posix.cc @@ -230,7 +230,7 @@ class PosixWritableFile : public WritableFile { ~PosixWritableFile() { if (fd_ >= 0) { // Ignoring any potential errors - FlushBuffered(); + Close(); } }