[Scummvm-git-logs] scummvm master -> e83fed6c60c869b89471cfc644097fae70d7521b

lephilousophe lephilousophe at users.noreply.github.com
Sun Jul 25 15:50:34 UTC 2021


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
e83fed6c60 COMMON: Fix 34cbff9dc26363ed3c8e518b13bf54af395771da


Commit: e83fed6c60c869b89471cfc644097fae70d7521b
    https://github.com/scummvm/scummvm/commit/e83fed6c60c869b89471cfc644097fae70d7521b
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2021-07-25T17:48:12+02:00

Commit Message:
COMMON: Fix 34cbff9dc26363ed3c8e518b13bf54af395771da

size got set in ensureCapacity which is not expected.
It must only increase when effectively writing in the buffer after
current end of file.

Changed paths:
    common/memstream.h


diff --git a/common/memstream.h b/common/memstream.h
index 7be976bc99..d0555200f9 100644
--- a/common/memstream.h
+++ b/common/memstream.h
@@ -186,13 +186,13 @@ protected:
 	uint32 _pos;
 	DisposeAfterUse::Flag _disposeMemory;
 
-	void ensureCapacity(uint32 new_len) {
-		if (new_len <= _capacity)
+	void ensureCapacity(uint32 capacity) {
+		if (capacity <= _capacity)
 			return;
 
 		byte *old_data = _data;
 
-		_capacity = MAX(new_len + 32, _capacity * 2);
+		_capacity = capacity;
 		_data = (byte *)malloc(_capacity);
 		_ptr = _data + _pos;
 
@@ -201,8 +201,6 @@ protected:
 			memcpy(_data, old_data, _size);
 			free(old_data);
 		}
-
-		_size = new_len;
 	}
 
 	/** Round up capacity to the next power of 2.
@@ -223,7 +221,7 @@ public:
 	}
 
 	uint32 write(const void *dataPtr, uint32 dataSize) override {
-		if ((_size + dataSize) >= _capacity)
+		if ((_pos + dataSize) >= _capacity)
 			ensureCapacity(roundUpCapacity(_pos + dataSize));
 
 		memcpy(_ptr, dataPtr, dataSize);




More information about the Scummvm-git-logs mailing list