all repos — mgba @ dbeff59c066c9e75f6359f1e4f9b4764eb99b7ff

mGBA Game Boy Advance Emulator

Core: Add some debug checks
Vicki Pfau vi@endrift.com
Sun, 24 Sep 2017 17:34:07 -0700
commit

dbeff59c066c9e75f6359f1e4f9b4764eb99b7ff

parent

405eafb969ef1ed55cb4792099cac7897c4f7713

1 files changed, 8 insertions(+), 0 deletions(-)

jump to
M src/core/tile-cache.csrc/core/tile-cache.c

@@ -194,6 +194,14 @@

static inline color_t* _tileLookup(struct mTileCache* cache, unsigned tileId, unsigned paletteId) { if (mTileCacheConfigurationIsShouldStore(cache->config)) { unsigned tiles = mTileCacheSystemInfoGetMaxTiles(cache->sysConfig); +#ifndef NDEBUG + if (tileId >= tiles) { + abort(); + } + if (paletteId >= 1 << mTileCacheSystemInfoGetPaletteCount(cache->sysConfig)) { + abort(); + } +#endif return &cache->cache[(tileId + paletteId * tiles) << 6]; } else { return cache->temporaryTile;