From f03db0115fa0a63fa5a1ae07974ce49c0a8a15dc Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sat, 3 Oct 2020 02:27:41 -0700 Subject: [PATCH] ircd::m::fed: Fix content/uri buffer reuse. --- matrix/fed.cc | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/matrix/fed.cc b/matrix/fed.cc index f8de220ec..31b3662fb 100644 --- a/matrix/fed.cc +++ b/matrix/fed.cc @@ -308,7 +308,7 @@ ircd::m::fed::frontfill::frontfill(const room::id &room_id, if(likely(!defined(json::get<"method"_>(opts.request)))) json::get<"method"_>(opts.request) = "POST"; - window_buffer buf{buf_}; + mutable_buffer buf{buf_}; if(likely(!defined(json::get<"uri"_>(opts.request)))) { thread_local char ridbuf[768]; @@ -323,15 +323,12 @@ ircd::m::fed::frontfill::frontfill(const room::id &room_id, if(likely(!defined(json::get<"content"_>(opts.request)))) { - buf([&pair, &opts](const mutable_buffer &buf) - { - return make_content(buf, pair, opts); - }); - json::get<"content"_>(opts.request) = json::object { - buf.completed() + make_content(buf, pair, opts) }; + + consume(buf, size(string_view(json::get<"content"_>(opts.request)))); } return request