From ca801b64458aacfbb9d71f2ffeeba2823565ed90 Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Sun, 26 Mar 2023 00:37:37 +0200 Subject: [PATCH] Fix crash in DDays "wake" map, #978 the HunkAlloc size calculated in calTexinfoAndFacesSize() was too small because that map has a *massive* water poly. Unfortunately it's not feasible to calculate the correct size (it depends on the size of the poly, for which I'd need the vertex coordinates, but to get them I'd have to load them first, which requires the allocation...), but allocating 5MB extra (instead of 1) made it work https://github.com/yquake2/yquake2/commit/c2d80c64eeef04db6aa8fe48e98736f9fee20741 --- src/vk/vk_model.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vk/vk_model.c b/src/vk/vk_model.c index 7299bdb..e562400 100644 --- a/src/vk/vk_model.c +++ b/src/vk/vk_model.c @@ -352,7 +352,7 @@ calcTexinfoAndFacesSize(const lump_t *fl, const byte *mod_base, const lump_t *tl // 256-55000 bytes are allocated (usually on the lower end), // so just assume 48k per face to be safe ret += numWarpFaces * 49152; - ret += 1000000; // and 1MB extra just in case + ret += 5000000; // and 5MB extra just in case return ret; } @@ -624,7 +624,7 @@ Mod_LoadBrushModel (model_t *mod, const void *buffer, int modfilelen) hunkSize += calcLumpHunkSize(&header->lumps[LUMP_LIGHTING], 1, 1); hunkSize += calcLumpHunkSize(&header->lumps[LUMP_PLANES], sizeof(dplane_t), sizeof(cplane_t)*2); hunkSize += calcTexinfoAndFacesSize(&header->lumps[LUMP_FACES], mod_base, &header->lumps[LUMP_TEXINFO]); - hunkSize += calcLumpHunkSize(&header->lumps[LUMP_LEAFFACES], sizeof(short), sizeof(msurface_t *)); // yes, out is indeeed a pointer! + hunkSize += calcLumpHunkSize(&header->lumps[LUMP_LEAFFACES], sizeof(short), sizeof(msurface_t *)); // yes, out is indeed a pointer! hunkSize += calcLumpHunkSize(&header->lumps[LUMP_VISIBILITY], 1, 1); hunkSize += calcLumpHunkSize(&header->lumps[LUMP_LEAFS], sizeof(dleaf_t), sizeof(mleaf_t)); hunkSize += calcLumpHunkSize(&header->lumps[LUMP_NODES], sizeof(dnode_t), sizeof(mnode_t));