From f2e240ab8ec2d6a47df1dce9c733c26581221bee Mon Sep 17 00:00:00 2001 From: Joao Eduardo Luis Date: Tue, 14 Jul 2015 16:52:35 +0100 Subject: [PATCH] messages: MForward: get() message reference Don't simply put() a reference if it has gone unclaimed without get()'ing it first. This can cause nefarious consequences for those users of MForward that do not expect this to happen. Signed-off-by: Joao Eduardo Luis --- src/messages/MForward.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/messages/MForward.h b/src/messages/MForward.h index 4d1abff3f8b..efe608563cd 100644 --- a/src/messages/MForward.h +++ b/src/messages/MForward.h @@ -102,12 +102,12 @@ public: } void set_message(PaxosServiceMessage *m, uint64_t features) { - encode_message(m, features, msg_bl); - - // keep a pointer to the message. We will not use it except for print(), - // and we will drop it in the dtor if it is not claimed. + // get a reference to the message. We will not use it except for print(), + // and we will put it in the dtor if it is not claimed. // we could avoid doing this if only we had a const bufferlist iterator :) - msg = m; + msg = (PaxosServiceMessage*)m->get(); + + encode_message(m, features, msg_bl); } PaxosServiceMessage *claim_message() { @@ -115,6 +115,7 @@ public: return get_msg_from_bl(); } + // let whoever is claiming the message deal with putting it. PaxosServiceMessage *m = msg; msg = NULL; return m; -- 2.47.3