From dbeff59c066c9e75f6359f1e4f9b4764eb99b7ff Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Sun, 24 Sep 2017 17:34:07 -0700 Subject: [PATCH] Core: Add some debug checks --- src/core/tile-cache.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/core/tile-cache.c b/src/core/tile-cache.c index ffb1cf565..2a7c8cf3a 100644 --- a/src/core/tile-cache.c +++ b/src/core/tile-cache.c @@ -194,6 +194,14 @@ static void _regenerateTile256(struct mTileCache* cache, color_t* tile, unsigned 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;