From: Dimitrian Date: Tue, 7 Feb 2023 21:12:29 +0000 (-0500) Subject: Fix number of bytes to be zeroed when spawn entity X-Git-Tag: xonotic-v0.8.6~2^2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=8aa262081d3a0837d15616e7cf82d2e1bb2745ca;p=xonotic%2Fgmqcc.git Fix number of bytes to be zeroed when spawn entity 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)`. --- diff --git a/exec.cpp b/exec.cpp index 387923f..7c82d64 100644 --- a/exec.cpp +++ b/exec.cpp @@ -212,7 +212,7 @@ static qcint_t prog_spawn_entity(qc_program_t *prog) { size_t sz = prog->entitydata.size(); prog->entitydata.resize(sz + prog->entityfields); data = (char*)&prog->entitydata[sz]; - memset(data, 0, sz * sizeof(qcint_t)); + memset(data, 0, prog->entityfields * sizeof(qcint_t)); return e; }