From 46ad6b1f38361a007e7a676ba2f94de8519dcad5 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 12 Dec 2017 16:47:42 +0800 Subject: [PATCH] Fixes ResizableBufferAdapter::resize doesn't consider the situation of new size which is lower than old size. (#1028) --- native/cocos/platform/CCFileUtils.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/native/cocos/platform/CCFileUtils.h b/native/cocos/platform/CCFileUtils.h index 617521dd07..3c745efff5 100644 --- a/native/cocos/platform/CCFileUtils.h +++ b/native/cocos/platform/CCFileUtils.h @@ -100,7 +100,8 @@ class ResizableBufferAdapter : public ResizableBuffer { public: explicit ResizableBufferAdapter(BufferType* buffer) : _buffer(buffer) {} virtual void resize(size_t size) override { - if (static_cast(_buffer->getSize()) < size) { + size_t oldSize = static_cast(_buffer->getSize()); + if (oldSize != size) { auto old = _buffer->getBytes(); void* buffer = realloc(old, size); if (buffer)