From 409dd8e3d9f41256ca64dd9771b12bb116dfb43b Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Wed, 28 Apr 2021 00:04:24 +0200 Subject: [PATCH] Fix crash if both image_useCache and image_downSize are 1 the commented out code clamped the loaded filesize of affected .dds images (crash observed with dds/guis/assets/splash/pdtempa.dds) to 200KB - but then later tries to load it and skip the first mipmap, resuling in reading invalid memory (> 200KB into the file). No idea what this was supposed to achieve, but it's disabled now and the crash (at startup) is gone. fixes #374 --- neo/renderer/Image_load.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/neo/renderer/Image_load.cpp b/neo/renderer/Image_load.cpp index 505793d0..50e2e206 100644 --- a/neo/renderer/Image_load.cpp +++ b/neo/renderer/Image_load.cpp @@ -1373,9 +1373,15 @@ bool idImage::CheckPrecompressedImage( bool fullLoad ) { return false; } +#if 0 // DG: no idea what this was exactly meant to achieve, but it's definitely a bad idea: + // we might try to load the lower mipmap levels of the image, but we'd still have + // to load the whole .dds file first. + // What's even weirder: idImage::ShouldImageBePartiallyCached() returns false + // if the file size is LESS THAN image_cacheMinK * 1024... if ( !fullLoad && len > globalImages->image_cacheMinK.GetInteger() * 1024 ) { len = globalImages->image_cacheMinK.GetInteger() * 1024; } +#endif byte *data = (byte *)R_StaticAlloc( len );