mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-05 06:15:35 +00:00
fixed a memory leak in the script record
This commit is contained in:
parent
3590fa40bd
commit
bf4ffe94dc
1 changed files with 5 additions and 5 deletions
|
@ -26,24 +26,24 @@ void Script::load(ESMReader &esm)
|
||||||
if (esm.isNextSub("SCVR"))
|
if (esm.isNextSub("SCVR"))
|
||||||
{
|
{
|
||||||
int s = mData.mStringTableSize;
|
int s = mData.mStringTableSize;
|
||||||
char* tmp = new char[s];
|
|
||||||
esm.getHExact(tmp, s);
|
std::vector<char> tmp (s);
|
||||||
|
esm.getHExact (&tmp[0], s);
|
||||||
|
|
||||||
// Set up the list of variable names
|
// Set up the list of variable names
|
||||||
mVarNames.resize(mData.mNumShorts + mData.mNumLongs + mData.mNumFloats);
|
mVarNames.resize(mData.mNumShorts + mData.mNumLongs + mData.mNumFloats);
|
||||||
|
|
||||||
// The tmp buffer is a null-byte separated string list, we
|
// The tmp buffer is a null-byte separated string list, we
|
||||||
// just have to pick out one string at a time.
|
// just have to pick out one string at a time.
|
||||||
char* str = tmp;
|
char* str = &tmp[0];
|
||||||
for (size_t i = 0; i < mVarNames.size(); i++)
|
for (size_t i = 0; i < mVarNames.size(); i++)
|
||||||
{
|
{
|
||||||
mVarNames[i] = std::string(str);
|
mVarNames[i] = std::string(str);
|
||||||
str += mVarNames[i].size() + 1;
|
str += mVarNames[i].size() + 1;
|
||||||
|
|
||||||
if (str - tmp > s)
|
if (str - &tmp[0] > s)
|
||||||
esm.fail("String table overflow");
|
esm.fail("String table overflow");
|
||||||
}
|
}
|
||||||
delete[] tmp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Script mData
|
// Script mData
|
||||||
|
|
Loading…
Reference in a new issue