In qcvm when zeroing memory for new entitydata wrong number of bytes used. This leads to crash with the error:malloc(): invalid size (unsorted).
Use prog->entityfields * sizeof(qcint_t)
instead of sz * sizeof(qcint_t).
sz is the size of the entitydata vector which is increased every time new entity spawned.
prog->entityfields is the number of entity fields and the size of the increment of the entitydata vector.
The issue can be reproduced with a simple QC program:
In
qcvm
when zeroing memory for new entitydata wrong number of bytes used. This leads to crash with the error:malloc(): invalid size (unsorted)
.Use
prog->entityfields * sizeof(qcint_t)
instead ofsz * sizeof(qcint_t)
.sz
is the size of theentitydata
vector which is increased every time new entity spawned.prog->entityfields
is the number of entity fields and the size of the increment of theentitydata
vector.The issue can be reproduced with a simple QC program:
The program above is compiled with
gmqcc
and executed withqcvm
.When program
progs.dat
is executed without the change the output is:When the same
progs.dat
is executed with the change in the PR the output is: