Skip to content

Commit

Permalink
pvr: avoid infinite loop if tile array is invalid
Browse files Browse the repository at this point in the history
Fixes 240pSuite freeze at boot with the libretro core.
  • Loading branch information
flyinghead committed Nov 2, 2024
1 parent cec4699 commit 65aadb9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion core/hw/pvr/ta_vtx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1664,14 +1664,17 @@ static void getRegionTileClipping(u32& xmin, u32& xmax, u32& ymin, u32& ymax)
getRegionTileAddrAndSize(addr, tile_size);

RegionArrayTile tile;
int maxTiles = 3000;
do {
tile.full = pvr_read32p<u32>(addr);
xmin = std::min(xmin, tile.X);
xmax = std::max(xmax, tile.X);
ymin = std::min(ymin, tile.Y);
ymax = std::max(ymax, tile.Y);
addr += tile_size;
} while (!tile.LastRegion);
} while (!tile.LastRegion && --maxTiles >= 0);
if (maxTiles < 0)
WARN_LOG(PVR, "getRegionTileClipping overflow");

xmin *= 32;
xmax *= 32;
Expand Down

0 comments on commit 65aadb9

Please sign in to comment.