diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2022-09-24 15:31:29 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2022-09-24 15:31:29 +0100 |
commit | b20b81d996b60b3e284843bd8034162ed1551927 (patch) | |
tree | ede702568b6c052aa4ba0f7254b0bb6939420b59 /src/libstat | |
parent | 213a260e6f190764cb3dd0868f10232a051b1f3a (diff) | |
download | rspamd-b20b81d996b60b3e284843bd8034162ed1551927.tar.gz rspamd-b20b81d996b60b3e284843bd8034162ed1551927.zip |
[Minor] Plug memory leak on cdb backend closing
Diffstat (limited to 'src/libstat')
-rw-r--r-- | src/libstat/backends/cdb_backend.cxx | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/libstat/backends/cdb_backend.cxx b/src/libstat/backends/cdb_backend.cxx index 36dbc9816..22a6c3dab 100644 --- a/src/libstat/backends/cdb_backend.cxx +++ b/src/libstat/backends/cdb_backend.cxx @@ -78,7 +78,7 @@ public: } else { /* Not existing, make a weak ptr and return the original */ - elts.emplace(path,std::weak_ptr<struct cdb>(cdbp)); + elts.emplace(path, std::weak_ptr<struct cdb>(cdbp)); return cdbp; } } @@ -92,6 +92,7 @@ private: struct cdb_deleter { void operator()(struct cdb *c) const { cdb_free(c); + delete c; } }; }; @@ -101,7 +102,7 @@ static cdb_shared_storage cdb_shared_storage; class ro_backend final { public: explicit ro_backend(struct rspamd_statfile *_st, cdb_shared_storage::cdb_element_t _db) - : st(_st), db(_db) {} + : st(_st), db(std::move(_db)) {} ro_backend() = delete; ro_backend(const ro_backend &) = delete; ro_backend(ro_backend &&other) noexcept { @@ -328,7 +329,7 @@ open_cdb(struct rspamd_statfile *st) -> tl::expected<ro_backend, std::string> path)); } - ro_backend bk{st, cdbp}; + ro_backend bk{st, std::move(cdbp)}; auto res = bk.load_cdb(); |