Skip to content

Commit

Permalink
Merge pull request #3320 from Ghabry/issue-3314
Browse files Browse the repository at this point in the history
ChangeSpriteAssociation: Fix OOB reads
  • Loading branch information
fdelapena authored Jan 4, 2025
2 parents 65478ef + fa5292b commit 8038b7b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/game_interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2112,8 +2112,17 @@ bool Game_Interpreter::CommandChangeSpriteAssociation(lcf::rpg::EventCommand con
}

auto file = ToString(CommandStringOrVariableBitfield(com, 3, 1, 4));
int idx = ValueOrVariableBitfield(com, 3, 2, 1);
bool transparent = com.parameters[2] != 0;

int idx = 0;
if (com.parameters.size() > 1) {
idx = ValueOrVariableBitfield(com, 3, 2, 1);
}

bool transparent = false;
if (com.parameters.size() > 2) {
transparent = com.parameters[2] != 0;
}

actor->SetSprite(file, idx, transparent);
Main_Data::game_player->ResetGraphic();
return true;
Expand Down

0 comments on commit 8038b7b

Please sign in to comment.