Fixes ResizableBufferAdapter<Data>::resize doesn't consider the situation of new size which is lower than old size. (#1028)

This commit is contained in:
James Chen
2017-12-12 16:47:42 +08:00
committed by GitHub
parent 0cfbfd08f7
commit 46ad6b1f38
+2 -1
View File
@@ -100,7 +100,8 @@ class ResizableBufferAdapter<Data> : public ResizableBuffer {
public:
explicit ResizableBufferAdapter(BufferType* buffer) : _buffer(buffer) {}
virtual void resize(size_t size) override {
if (static_cast<size_t>(_buffer->getSize()) < size) {
size_t oldSize = static_cast<size_t>(_buffer->getSize());
if (oldSize != size) {
auto old = _buffer->getBytes();
void* buffer = realloc(old, size);
if (buffer)