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
This commit is contained in:
Daniel Gibson 2021-04-28 00:04:24 +02:00
parent 5f346c7355
commit 409dd8e3d9

View file

@ -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 );