# HG changeset patch # User Grumpy7 # Date 1406147093 -7200 # Node ID ed1e4cff79a27d60c4db87ed93544b9120bf8163 # Parent 9f30d514cdd218b17c64049b2f3e1745715e5b90 fixed uninitialized memory access in SpriteFrameTable::FromFile diff -r 9f30d514cdd2 -r ed1e4cff79a2 Sprites.cpp --- a/Sprites.cpp Wed Jul 23 19:52:49 2014 +0100 +++ b/Sprites.cpp Wed Jul 23 22:24:53 2014 +0200 @@ -406,17 +406,9 @@ memcpy(pSpriteSFrames + num_mm6_frames + num_mm7_frames, (char *)data_mm8 + 8, mm8_frames_size); memcpy(pSpriteEFrames + num_mm6_frames + num_mm7_frames, (char *)data_mm8 + 8 + mm8_frames_size, 2 * num_mm8_eframes); - for (uint i = 0; i < num_mm7_frames; ++i) - pSpritePFrames[i] = &pSpriteSFrames[pSpriteEFrames[i]];//Uninitialized memory access - - for (uint i = num_mm7_frames; i < num_mm6_frames + num_mm7_frames; ++i) - pSpritePFrames[i] = &pSpriteSFrames[pSpriteEFrames[i] + num_mm7_frames]; - - for (uint i = num_mm6_frames + num_mm7_frames; i < num_mm6_frames + num_mm7_frames + num_mm8_frames; ++i) - pSpritePFrames[i] = &pSpriteSFrames[pSpriteEFrames[i] + num_mm6_frames + num_mm7_frames]; - - //for (uint i = 0; i < uNumSpriteFrames; ++i) - // pSpritePFrames[i] = &pSpriteSFrames[pSpriteEFrames[i]]; + //the original was using num_mmx_frames, but never accessed any element beyond num_mmx_eframes, but boing beyong eframes caused invalid memory accesses + for (uint i = 0; i < num_mm6_eframes + num_mm7_eframes + num_mm8_eframes; ++i) + pSpritePFrames[i] = &pSpriteSFrames[pSpriteEFrames[i]]; } //----- (0044DA92) --------------------------------------------------------