From 80f947024a5a4c66d8f7ec88ba0e86f0d4f3dada Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Thu, 17 Feb 2022 23:46:44 +0200 Subject: [PATCH] server: lock run_query So the query-results don't outlive the lock. --- lib/mu-server.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/mu-server.cc b/lib/mu-server.cc index 82cd527e..68bc5a04 100644 --- a/lib/mu-server.cc +++ b/lib/mu-server.cc @@ -566,6 +566,7 @@ docids_for_msgid(const Store& store, const std::string& msgid, size_t max = 100) g_free(tmp); GError* gerr{}; + std::lock_guard l{store.lock()}; const auto res{store.run_query(expr, MU_MSG_FIELD_ID_NONE, QueryFlags::None, max)}; g_free(expr); if (!res) @@ -692,6 +693,7 @@ Server::Private::find_handler(const Parameters& params) if (threads) qflags |= QueryFlags::Threading; + std::lock_guard l{store_.lock()}; auto qres{store_.run_query(q, sort_field, qflags, maxnum)}; if (!qres) throw Error(Error::Code::Query, "failed to run query");