aboutsummaryrefslogtreecommitdiff
path: root/engines/dreamweb/vgagrafx.cpp
diff options
context:
space:
mode:
authorColin Snover2017-11-11 16:11:06 -0600
committerColin Snover2017-11-12 23:15:05 -0600
commita6659ba9d577998139cbb9a61532f823a24bc3b9 (patch)
treecccf6501b521fc8c20d3faf05ec1edbe2c711ea2 /engines/dreamweb/vgagrafx.cpp
parent0eda63bed1b2d7fe0dba1360cad880b826248eaa (diff)
downloadscummvm-rg350-a6659ba9d577998139cbb9a61532f823a24bc3b9.tar.gz
scummvm-rg350-a6659ba9d577998139cbb9a61532f823a24bc3b9.tar.bz2
scummvm-rg350-a6659ba9d577998139cbb9a61532f823a24bc3b9.zip
DREAMWEB: Use accurate memory reclamation for Ex transfers
When the Ex memory regions are close to full, it is possible for the game to fail to purge objects and then crash with an OOM error even if it isn't actually out of memory. This patch calculates the amount of free memory truly needed when allocating to Ex memory to allow exactly the entire frame & text regions to be used, instead previously where a hard-coded amount of free space to maintain was used, which guaranteed that the entire memory region could not actually be used by the game. This change may be masking some underlying memory leak, or it may just be that near the end of the game the game naturally comes close to reaching the maximum memory region size. For the moment, I am assuming the latter. This commit also adds some assertion checks to the memory transfer functions to make sure the regions don't quietly overflow in other cases, since pickupConts performs transfers in a manner that doesn't ensure enough free memory exists for them to be successful. Fixes Trac#6820.
Diffstat (limited to 'engines/dreamweb/vgagrafx.cpp')
-rw-r--r--engines/dreamweb/vgagrafx.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/engines/dreamweb/vgagrafx.cpp b/engines/dreamweb/vgagrafx.cpp
index aa58352e81..2eba37579a 100644
--- a/engines/dreamweb/vgagrafx.cpp
+++ b/engines/dreamweb/vgagrafx.cpp
@@ -425,6 +425,7 @@ void DreamWebEngine::transferFrame(uint8 from, uint8 to, uint8 offset) {
const uint8 *src = _freeFrames.getFrameData(3*from + offset);
uint8 *dst = _exFrames._data + _vars._exFramePos;
+ assert(_vars._exFramePos + byteCount <= kExframeslen);
memcpy(dst, src, byteCount);
exFrame.setPtr(_vars._exFramePos);