aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver/hyperscan_tools.cxx
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2023-02-27 22:02:11 +0000
committerVsevolod Stakhov <vsevolod@rspamd.com>2023-02-27 22:02:11 +0000
commit92aa771c16d2aa1449874ec3906f7441ad3fb2f1 (patch)
treebdafb8585b59497915a05640d1ce0619ca17bcd5 /src/libserver/hyperscan_tools.cxx
parente88a512b2f370b3fcf5b0ff1205a0a84d156e060 (diff)
downloadrspamd-92aa771c16d2aa1449874ec3906f7441ad3fb2f1.tar.gz
rspamd-92aa771c16d2aa1449874ec3906f7441ad3fb2f1.zip
[Minor] Avoid to initialise string with nullptr
Diffstat (limited to 'src/libserver/hyperscan_tools.cxx')
-rw-r--r--src/libserver/hyperscan_tools.cxx12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/libserver/hyperscan_tools.cxx b/src/libserver/hyperscan_tools.cxx
index 034184cba..296d27335 100644
--- a/src/libserver/hyperscan_tools.cxx
+++ b/src/libserver/hyperscan_tools.cxx
@@ -289,7 +289,15 @@ struct hs_shared_database {
explicit hs_shared_database(raii_mmaped_file &&map, hs_database_t *db) : db(db), maybe_map(std::move(map)) {
cached_path = maybe_map.value().get_file().get_name();
}
- explicit hs_shared_database(hs_database_t *db, const char *fname) : db(db), maybe_map(std::nullopt), cached_path{fname} {}
+ explicit hs_shared_database(hs_database_t *db, const char *fname) : db(db), maybe_map(std::nullopt) {
+ if (fname) {
+ cached_path = fname;
+ }
+ else {
+ /* Likely a test case */
+ cached_path = "";
+ }
+ }
hs_shared_database(const hs_shared_database &other) = delete;
hs_shared_database() = default;
hs_shared_database(hs_shared_database &&other) noexcept {
@@ -529,7 +537,7 @@ rspamd_hyperscan_free(rspamd_hyperscan_t *db, bool invalid)
{
auto *real_db = CXX_DB_FROM_C(db);
- if (invalid) {
+ if (invalid && !real_db->cached_path.empty()) {
rspamd::util::hs_known_files_cache::get().delete_cached_file(real_db->cached_path.c_str());
}
delete real_db;