GobySoft / goby3

The Goby Underwater Autonomy Project Version 3
Other
24 stars 11 forks source link

Fix computation of buffer size in DynamicBuffer #292

Closed tsaubergine closed 1 year ago

tsaubergine commented 1 year ago

Bug: if a DynamicSubBuffer contains several messages of different sizes, and one or more of them has been requested but the ack timeout has not been exceeded, the computation of the next message size is incorrect.

e.g. SubBuffer "A" has messages of 30, 40, and 50 bytes. If the 30 byte message has been accessed (via top()) the next call to top_value would use 30 bytes (not 40 bytes) as the size to check when ensuring the next message isn't too long. In this case (where the next message is larger than the first), it is possible to incorrectly return a value when it actually exceeds the max_bytes requested.

This PR fixes this bug by correctly computing the size of the next message in the same fashion as it is accessed, using a new top_size() method.