GNAP: Fix potential out of bound write

This commit is contained in:
Strangerke 2016-06-08 07:46:35 +02:00
parent 245ae4011b
commit 32f9b92431

View file

@ -1116,7 +1116,10 @@ void GameSys::fatUpdateFrame() {
if (_newSpriteDrawItemsCount > 0) {
debugC(kDebugBasic, "_newSpriteDrawItemsCount: %d", _newSpriteDrawItemsCount);
for (int k = 0; k < _newSpriteDrawItemsCount; ++k) {
if (_gfxItemsCount < 50) {
// The original was allowing a buffer overflow.
// In order to fit in memory, insertIndex + 1 + (_gfxItemsCount - InsertIndex) must be
// smaller than the size _gfxItems array (50).
if (_gfxItemsCount + 1 < 50) {
int insertIndex;
seqLocateGfx(-1, _newSpriteDrawItems[k]._id, &insertIndex);
if (_gfxItemsCount != insertIndex)