Skip to content

Commit 8038b7b

Browse files
author
fdelapena
authored
Merge pull request #3320 from Ghabry/issue-3314
ChangeSpriteAssociation: Fix OOB reads
2 parents 65478ef + fa5292b commit 8038b7b

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/game_interpreter.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2112,8 +2112,17 @@ bool Game_Interpreter::CommandChangeSpriteAssociation(lcf::rpg::EventCommand con
21122112
}
21132113

21142114
auto file = ToString(CommandStringOrVariableBitfield(com, 3, 1, 4));
2115-
int idx = ValueOrVariableBitfield(com, 3, 2, 1);
2116-
bool transparent = com.parameters[2] != 0;
2115+
2116+
int idx = 0;
2117+
if (com.parameters.size() > 1) {
2118+
idx = ValueOrVariableBitfield(com, 3, 2, 1);
2119+
}
2120+
2121+
bool transparent = false;
2122+
if (com.parameters.size() > 2) {
2123+
transparent = com.parameters[2] != 0;
2124+
}
2125+
21172126
actor->SetSprite(file, idx, transparent);
21182127
Main_Data::game_player->ResetGraphic();
21192128
return true;

0 commit comments

Comments
 (0)