mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-12 23:54:35 +00:00
- fixed memory leak in ZScript backend.
This allocated some memory and never freed it again. A TArray would have been better - but since we know the maximum size is 4 we may just use a static array here to keep things as efficient as possible.
This commit is contained in:
parent
65a26d6779
commit
ffdd0a11ea
1 changed files with 6 additions and 5 deletions
|
@ -723,16 +723,17 @@ ExpEmit FxVectorValue::Emit(VMFunctionBuilder *build)
|
||||||
{
|
{
|
||||||
if (e) vectorElements++;
|
if (e) vectorElements++;
|
||||||
}
|
}
|
||||||
assert(vectorElements > 0);
|
assert(vectorElements > 0 && vectorElements <= 4);
|
||||||
|
|
||||||
ExpEmit* tempVal = (ExpEmit*)calloc(vectorElements, sizeof(ExpEmit));
|
// We got at most 4 elements
|
||||||
ExpEmit* val = (ExpEmit*)calloc(vectorElements, sizeof(ExpEmit));
|
ExpEmit tempVal[4];
|
||||||
|
ExpEmit val[4];
|
||||||
|
|
||||||
// Init ExpEmit
|
// Init ExpEmit
|
||||||
for (int i = 0; i < vectorElements; ++i)
|
for (int i = 0; i < vectorElements; ++i)
|
||||||
{
|
{
|
||||||
new(tempVal + i) ExpEmit(xyzw[i]->Emit(build));
|
tempVal[i] = ExpEmit(xyzw[i]->Emit(build));
|
||||||
new(val + i) ExpEmit(EmitKonst(build, tempVal[i]));
|
val[i] = EmitKonst(build, tempVal[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue