diff options
author | Martin Kiewitz | 2016-02-08 20:49:22 +0100 |
---|---|---|
committer | Martin Kiewitz | 2016-02-08 20:49:22 +0100 |
commit | 2a883bdd424a166215eeeecf6876ac1cc30fb8bd (patch) | |
tree | fdd4de068f6721d1a10268cb09dd5b6d8dd98077 /engines/sci | |
parent | 92f1062a3bd454f3a74d5f375512f7e071d198c0 (diff) | |
download | scummvm-rg350-2a883bdd424a166215eeeecf6876ac1cc30fb8bd.tar.gz scummvm-rg350-2a883bdd424a166215eeeecf6876ac1cc30fb8bd.tar.bz2 scummvm-rg350-2a883bdd424a166215eeeecf6876ac1cc30fb8bd.zip |
SCI: Zero out dynamically allocated memory
Fixes Mixed Up Mother Goose SCI1.1 crash when saving
And could potentially fix all sorts of other issues
Original SCI only zeroed out heap on init.
Diffstat (limited to 'engines/sci')
-rw-r--r-- | engines/sci/engine/seg_manager.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/engines/sci/engine/seg_manager.cpp b/engines/sci/engine/seg_manager.cpp index 23b1fdae23..8090b1861d 100644 --- a/engines/sci/engine/seg_manager.cpp +++ b/engines/sci/engine/seg_manager.cpp @@ -837,10 +837,13 @@ byte *SegManager::allocDynmem(int size, const char *descr, reg_t *addr) { d._size = size; - if (size == 0) + // Original SCI only zeroed out heap memory on initialize + // They didn't do it again for every allocation + if (size) { + d._buf = (byte *)calloc(size, 1); + } else { d._buf = NULL; - else - d._buf = (byte *)malloc(size); + } d._description = descr; |