Skip to content

Commit

Permalink
fix infinite loop in rosbag buffer resize (#1623)
Browse files Browse the repository at this point in the history
* fix infinite loop in rosbag buffer resize

* grow to max size
  • Loading branch information
ipa-fez authored and dirk-thomas committed Feb 20, 2019
1 parent 4833dc8 commit acd8313
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tools/rosbag_storage/src/buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <stdlib.h>
#include <assert.h>
#include <utility>
#include <limits>

#include "rosbag/buffer.h"

Expand Down Expand Up @@ -65,7 +66,12 @@ void Buffer::ensureCapacity(uint32_t capacity) {
capacity_ = capacity;
else {
while (capacity_ < capacity)
{
if (static_cast<uint64_t>(capacity) * 2 > std::numeric_limits<uint32_t>::max())
capacity_ = std::numeric_limits<uint32_t>::max();
else
capacity_ *= 2;
}
}

buffer_ = (uint8_t*) realloc(buffer_, capacity_);
Expand Down

0 comments on commit acd8313

Please sign in to comment.