utils: PopTransform: Guard against negative indexes

This commit is contained in:
Sebastian Krzyszkowiak 2022-07-21 08:45:56 +02:00
parent 84c56bb12b
commit ca1cbc19b7
No known key found for this signature in database
GPG key ID: E8F235CF3BDBC3FF

View file

@ -673,6 +673,10 @@ SYMBOL_EXPORT void PushTransform(struct Game* game, ALLEGRO_TRANSFORM* t) {
} }
SYMBOL_EXPORT void PopTransform(struct Game* game) { SYMBOL_EXPORT void PopTransform(struct Game* game) {
if (game->_priv.transforms_no == 0) {
PrintConsole(game, "Tried to pop a non-existent transform!");
return;
}
al_use_transform(&game->_priv.transforms[--game->_priv.transforms_no]); al_use_transform(&game->_priv.transforms[--game->_priv.transforms_no]);
} }