diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sci/engine/object.cpp | 10 | ||||
-rw-r--r-- | engines/sci/engine/object.h | 13 |
2 files changed, 16 insertions, 7 deletions
diff --git a/engines/sci/engine/object.cpp b/engines/sci/engine/object.cpp index ed78a5fc2d..99527b5d1a 100644 --- a/engines/sci/engine/object.cpp +++ b/engines/sci/engine/object.cpp @@ -61,13 +61,13 @@ void Object::init(byte *buf, reg_t obj_pos, bool initVariables) { if (getSciVersion() <= SCI_VERSION_1_LATE) { _variables.resize(READ_LE_UINT16(data + kOffsetSelectorCounter)); - _baseVars = (const uint16 *)(_baseObj + _variables.size() * 2); + _baseVars = (uint16 *)(_baseObj + _variables.size() * 2); _methodCount = READ_LE_UINT16(data + READ_LE_UINT16(data + kOffsetFunctionArea) - 2); _baseMethod = Common::Array<uint16>((const uint16 *)(data + READ_LE_UINT16(data + kOffsetFunctionArea)), _methodCount*2+2); } else if (getSciVersion() >= SCI_VERSION_1_1 && getSciVersion() <= SCI_VERSION_2_1) { _variables.resize(READ_SCI11ENDIAN_UINT16(data + 2)); - _baseVars = (const uint16 *)(buf + READ_SCI11ENDIAN_UINT16(data + 4)); + _baseVars = (uint16 *)(buf + READ_SCI11ENDIAN_UINT16(data + 4)); _methodCount = READ_SCI11ENDIAN_UINT16(buf + READ_SCI11ENDIAN_UINT16(data + 6)); _baseMethod = Common::Array<uint16>((const uint16 *) (buf + READ_SCI11ENDIAN_UINT16(data + 6)), _methodCount*2+3); @@ -222,9 +222,9 @@ void Object::initSelectorsSci3(const byte *buf) { } _variables.resize(properties); - uint16 *propertyIds = (uint16*) malloc(sizeof(uint16)*properties); -// uint16 *methodOffsets = (uint16*) malloc(sizeof(uint16)*2*methods); - uint16 *propertyOffsets = (uint16*) malloc(sizeof(uint16)*properties); + uint16 *propertyIds = (uint16 *) malloc(sizeof(uint16) * properties); +// uint16 *methodOffsets = (uint16 *) malloc(sizeof(uint16) * 2 * methods); + uint16 *propertyOffsets = (uint16 *) malloc(sizeof(uint16) * properties); int propertyCounter = 0; int methodCounter = 0; diff --git a/engines/sci/engine/object.h b/engines/sci/engine/object.h index f59874bb44..81d5b2c983 100644 --- a/engines/sci/engine/object.h +++ b/engines/sci/engine/object.h @@ -69,7 +69,16 @@ public: _propertyOffsetsSci3 = 0; } - ~Object() { free(_propertyOffsetsSci3); } + ~Object() { + if (getSciVersion() == SCI_VERSION_3) { + // FIXME: memory leak! Commented out because of reported heap + // corruption by MSVC (e.g. in LSL7, when it starts) + //free(_baseVars); + //_baseVars = 0; + //free(_propertyOffsetsSci3); + //_propertyOffsetsSci3 = 0; + } + } reg_t getSpeciesSelector() const { if (getSciVersion() <= SCI_VERSION_2_1) @@ -229,7 +238,7 @@ private: void initSelectorsSci3(const byte *buf); const byte *_baseObj; /**< base + object offset within base */ - const uint16 *_baseVars; /**< Pointer to the varselector area for this object */ + uint16 *_baseVars; /**< Pointer to the varselector area for this object */ Common::Array<uint16> _baseMethod; /**< Pointer to the method selector area for this object */ uint16 *_propertyOffsetsSci3; /**< This is used to enable relocation of property valuesa in SCI3 */ |