diff options
author | Max Horn | 2010-06-01 15:38:34 +0000 |
---|---|---|
committer | Max Horn | 2010-06-01 15:38:34 +0000 |
commit | 1f54cdf90d5d14c4acee4cd2a358585b43abb188 (patch) | |
tree | e5aa59ffd479236074e69c29ab09ceb92ac9b8d4 /engines/sci/engine/kernel32.cpp | |
parent | caf1a6bee4bb60014290a2208ec0daa0c68496cd (diff) | |
download | scummvm-rg350-1f54cdf90d5d14c4acee4cd2a358585b43abb188.tar.gz scummvm-rg350-1f54cdf90d5d14c4acee4cd2a358585b43abb188.tar.bz2 scummvm-rg350-1f54cdf90d5d14c4acee4cd2a358585b43abb188.zip |
SCI: Fix malloc<->new mismatch in SysStrings, try to increase readability
svn-id: r49375
Diffstat (limited to 'engines/sci/engine/kernel32.cpp')
-rw-r--r-- | engines/sci/engine/kernel32.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/engines/sci/engine/kernel32.cpp b/engines/sci/engine/kernel32.cpp index 3dd596494d..b132543206 100644 --- a/engines/sci/engine/kernel32.cpp +++ b/engines/sci/engine/kernel32.cpp @@ -577,14 +577,14 @@ reg_t kString(EngineState *s, int argc, reg_t *argv) { // We have a special case here for argv[1] being a system string if (argv[1].segment == s->_segMan->getSysStringsSegment()) { // Resize if necessary - if ((uint32)s->_segMan->sysStrings->_strings[argv[1].toUint16()]._maxSize < index1 + count) { - delete[] s->_segMan->sysStrings->_strings[argv[1].toUint16()]._value; - s->_segMan->sysStrings->_strings[argv[1].toUint16()]._maxSize = index1 + count; - s->_segMan->sysStrings->_strings[argv[1].toUint16()]._value = new char[index1 + count]; - memset(s->_segMan->sysStrings->_strings[argv[1].toUint16()]._value, 0, index1 + count); + const uint16 sysStringId = argv[1].toUint16(); + if ((uint32)s->_segMan->sysStrings->_strings[sysStringId]._maxSize < index1 + count) { + free(s->_segMan->sysStrings->_strings[sysStringId]._value); + s->_segMan->sysStrings->_strings[sysStringId]._maxSize = index1 + count; + s->_segMan->sysStrings->_strings[sysStringId]._value = (char *)calloc(index1 + count, sizeof(char)); } - strncpy(s->_segMan->sysStrings->_strings[argv[1].toUint16()]._value + index1, string2.c_str() + index2, count); + strncpy(s->_segMan->sysStrings->_strings[sysStringId]._value + index1, string2.c_str() + index2, count); } else { SciString *string1 = s->_segMan->lookupString(argv[1]); |