Don't increment number of status items before comparing with maximum.

Fixes segfault when connecting an USB disk and all of the 10 slots are in use.
This commit is contained in:
Volker Ruppert 2021-04-23 20:08:12 +00:00
parent 77cc12cce5
commit 6781067b55

View File

@ -934,8 +934,10 @@ int bx_gui_c::register_statusitem(const char *text, bool auto_off)
}
}
if (id == statusitem_count) {
if (++statusitem_count > BX_MAX_STATUSITEMS) {
if (statusitem_count == BX_MAX_STATUSITEMS) {
return -1;
} else {
statusitem_count++;
}
}
statusitem[id].in_use = 1;