From b4e7f84704b0bb8ed8834d307d24a4c5487619de Mon Sep 17 00:00:00 2001 From: Martin Hurton Date: Tue, 8 May 2012 09:28:17 +0200 Subject: Fix issue #268 This patch fixes a bug in the message encoder which was responsible for computing incorrect message offset. The bug affected PGM receiver making it unable to decode inital messages. --- src/encoder.hpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/encoder.hpp') diff --git a/src/encoder.hpp b/src/encoder.hpp index 0883f9d..406b28a 100644 --- a/src/encoder.hpp +++ b/src/encoder.hpp @@ -83,19 +83,19 @@ namespace xs // If there are still no data, return what we already have // in the buffer. if (!to_write) { + + // If we are to encode the beginning of a new message, + // adjust the message offset. + if (beginning) + if (offset_ && *offset_ == -1) + *offset_ = static_cast (pos); + if (!(static_cast (this)->*next) ()) { *data_ = buffer; *size_ = pos; return false; } - // If beginning of the message was processed, adjust the - // first-message-offset. - if (beginning) { - if (offset_ && *offset_ == -1) - *offset_ = (int) pos; - beginning = false; - } } // If there are no data in the buffer yet and we are able to -- cgit v1.2.3