Skip to content

Commit 3d976f5

Browse files
committed
fix a rare crash in the tech room
The tech room loop checked that all the lines could fit in the available screen real estate, but it didn't check to see that the number of lines was less than the array capacity. Normally this never happened, but certain mods which use smaller fonts will overflow the limit. This adds a proper bounds check and also increases the bounds so that more of the smaller lines can be used.
1 parent e5af389 commit 3d976f5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

code/menuui/techmenu.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
#define NUM_BUTTONS 16
4545
#define NUM_TABS 3
46-
#define LIST_BUTTONS_MAX 42
46+
#define LIST_BUTTONS_MAX 50
4747

4848
#define SHIPS_DATA_MODE (1<<0)
4949
#define WEAPONS_DATA_MODE (1<<1)
@@ -430,7 +430,7 @@ void tech_common_render()
430430
y = 0;
431431
z = List_offset;
432432
while (y + font_height <= Tech_list_coords[gr_screen.res][SHIP_H_COORD]) {
433-
if (z >= static_cast<int>(Current_list->size())) {
433+
if ((z - List_offset) >= LIST_BUTTONS_MAX || z >= static_cast<int>(Current_list->size())) {
434434
break;
435435
}
436436

0 commit comments

Comments
 (0)