From 8aa262081d3a0837d15616e7cf82d2e1bb2745ca Mon Sep 17 00:00:00 2001 From: Dimitrian Date: Tue, 7 Feb 2023 16:12:29 -0500 Subject: [PATCH] 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)`. --- exec.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; } -- 2.39.2