From bb386c5ab427d7f1f20d7bd831bcb81554fc4929 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Fri, 18 Sep 2020 19:06:50 -0700 Subject: [PATCH] ircd::m::event: Fix integer value recast (assertion from 8ab735d002). --- matrix/event_index.cc | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/matrix/event_index.cc b/matrix/event_index.cc index cf8ae7038..57cc76cb9 100644 --- a/matrix/event_index.cc +++ b/matrix/event_index.cc @@ -53,21 +53,27 @@ ircd::m::event::idx ircd::m::index(std::nothrow_t, const event::id &event_id) { - auto &column + static auto &column { dbs::event_idx }; - bool found; - alignas(8) char buf[8] {0}; + bool found {false}; + event::idx ret {0}; if(likely(event_id)) - read(column, event_id, found, buf); - - constexpr bool safety(false); // we know buf is the right size - return byte_view { - buf - }; + const mutable_buffer buf + { + reinterpret_cast(&ret), sizeof(ret) + }; + + const string_view val + { + read(column, event_id, found, buf) + }; + } + + return ret & boolmask(found); } bool