Skip to content

Commit

Permalink
Fix crash on bar 0/0
Browse files Browse the repository at this point in the history
  • Loading branch information
TellowKrinkle committed Jun 12, 2021
1 parent 8007b6d commit 4ff752c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/PonscripterLabel_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3713,6 +3713,11 @@ int PonscripterLabel::barCommand(const pstring& cmd)

bar_info[no]->color = readColour(script_h.readStrValue());

if (bar_info[no]->max_param == 0) {
// Prevent divide-by-zero errors
bar_info[no]->max_param = 1;
}

int w = bar_info[no]->max_width * bar_info[no]->param / bar_info[no]->max_param;
if (bar_info[no]->max_width > 0 && w > 0) {
bar_info[no]->pos.w = w;
Expand Down

0 comments on commit 4ff752c

Please sign in to comment.