From 69026c31a33eed366147e13f0038f20e44b52c01 Mon Sep 17 00:00:00 2001 From: Emiel Bruijntjes Date: Tue, 18 Aug 2020 12:33:38 +0200 Subject: [PATCH] fixed crash because the wrong size was passed --- src/basicheaderframe.h | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/basicheaderframe.h b/src/basicheaderframe.h index bc60a17..c33a81b 100644 --- a/src/basicheaderframe.h +++ b/src/basicheaderframe.h @@ -1,7 +1,7 @@ /** * Class describing an AMQP basic header frame * - * @copyright 2014 - 2018 Copernica BV + * @copyright 2014 - 2020 Copernica BV */ /** @@ -66,6 +66,18 @@ protected: _metadata.fill(buffer); } + /** + * Construct an empty basic header frame + * @param channel channel we're working on + * @param metadata the meta-data + * @param bodysize size of the body + */ + BasicHeaderFrame(uint16_t channel, const MetaData &metadata, size_t bodysize) : + HeaderFrame(channel, 10 + metadata.size()), // there are at least 10 bytes sent, weight (2), bodySize (8), plus the size of the meta data + _bodySize(bodysize), + _metadata(metadata) + {} + public: /** * Construct an empty basic header frame @@ -76,10 +88,7 @@ public: * @param envelope the envelope */ BasicHeaderFrame(uint16_t channel, const Envelope &envelope) : - HeaderFrame(channel, 10 + envelope.size()), // there are at least 10 bytes sent, weight (2), bodySize (8), plus the size of the meta data - _bodySize(envelope.bodySize()), - _metadata(envelope) - {} + BasicHeaderFrame(channel, envelope, envelope.bodySize()) {} /** * Constructor to parse incoming frame