From f6ce3a447c10981b01d34438a0452ebd820408c8 Mon Sep 17 00:00:00 2001 From: In-line Date: Sat, 21 Jan 2017 13:14:29 +0400 Subject: [PATCH] Move model->numleafs check to Mod_LoadLeafs --- rehlds/engine/cmodel.cpp | 7 +++++-- rehlds/engine/model.cpp | 9 +++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/rehlds/engine/cmodel.cpp b/rehlds/engine/cmodel.cpp index 21d6ae4..8bd9edf 100644 --- a/rehlds/engine/cmodel.cpp +++ b/rehlds/engine/cmodel.cpp @@ -47,15 +47,18 @@ unsigned char *Mod_DecompressVis(unsigned char *in, model_t *model) { return mod_novis; } - +#ifdef REHLDS_FIXES + CM_DecompressPVS(in, decompressed, (model->numleafs + 7) / 8); +#else int row = (model->numleafs + 7) / 8; - // TODO: Move to model loading code + if (row < 0 || row > MODEL_MAX_PVS) { Sys_Error(__FUNCTION__ ": oversized model->numleafs: %i", model->numleafs); } CM_DecompressPVS(in, decompressed, row); +#endif return decompressed; } diff --git a/rehlds/engine/model.cpp b/rehlds/engine/model.cpp index c6283fc..d8796b5 100644 --- a/rehlds/engine/model.cpp +++ b/rehlds/engine/model.cpp @@ -1033,7 +1033,16 @@ void Mod_LoadLeafs(lump_t *l) loadmodel->leafs = out; loadmodel->numleafs = count; +#ifdef REHLDS_FIXES + { + int row = (loadmodel->numleafs + 7) / 8; + if (row < 0 || row > MODEL_MAX_PVS) + { + Sys_Error(__FUNCTION__ ": oversized loadmodel->numleafs: %i", loadmodel->numleafs); + } + } +#endif for (i = 0; i < count; i++, in++, out++) { for (j = 0; j < 3; j++)