mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-13 21:31:53 +00:00
SCI: Fix malloc<->new mismatch in SysStrings, try to increase readability
svn-id: r49375
This commit is contained in:
parent
caf1a6bee4
commit
1f54cdf90d
@ -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]);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user