Avoid calling IsValidRange with zero length

This commit is contained in:
Henrik Rydgård
2025-12-30 20:26:02 +01:00
parent 4ef11c8262
commit fb521408c7
2 changed files with 3 additions and 2 deletions
+2 -1
View File
@@ -1418,10 +1418,11 @@ bool PPGeImage::IsValid() {
if (loadFailed_)
return false;
if (!Memory::IsValidRange(this->png_, (u32)this->size_)) {
if (size_ && !Memory::IsValidRange(this->png_, (u32)this->size_)) {
return false;
}
// TODO: It's really wacky to call Decimate from in here.
if (texture_ == 0) {
Decimate();
return Load();
+1 -1
View File
@@ -1683,7 +1683,7 @@ static CheckAlphaResult DecodeDXTBlocks(uint8_t *out, int outPitch, uint32_t tex
int outPitch32 = outPitch / sizeof(uint32_t);
const DXTBlock *src = (const DXTBlock *)texptr;
if (!Memory::IsValidRange(texaddr, (h / 4) * (bufw / 4) * sizeof(DXTBlock))) {
if (!Memory::IsValidRange(texaddr, ((h + 3) / 4) * (bufw / 4) * sizeof(DXTBlock))) {
ERROR_LOG_REPORT(Log::G3D, "DXT%d texture extends beyond valid RAM: %08x + %d x %d", n, texaddr, bufw, h);
uint32_t limited = Memory::ValidSize(texaddr, (h / 4) * (bufw / 4) * sizeof(DXTBlock));
// This might possibly be 0, but try to decode what we can (might even be how the PSP behaves.)