Core: Add some debug checks
Vicki Pfau vi@endrift.com
Sun, 24 Sep 2017 17:34:07 -0700
1 files changed,
8 insertions(+),
0 deletions(-)
jump to
M
src/core/tile-cache.c
→
src/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;