[BugFix] printcell_helper selection out of bounds

on load printcell.selcol is -1 whioch is out of bounds as an index into an array

Change-Id: I1e823712d268537d5d444458993ec2aa2cd253ff
This commit is contained in:
William Wilgus 2022-12-31 10:45:29 -05:00 committed by William Wilgus
parent 485e96d6be
commit 0330aa8eb2

View file

@ -192,7 +192,9 @@ static inline int calcvisible(int screen, int vp_w, int text_offset, int sbwidth
uint16_t *screencolwidth = printcell.colw[screen];
int screenicnwidth = printcell.iconw[screen];
int offset = 0;
int selcellw = screencolwidth[printcell.selcol] + text_offset;
int selcellw = 0;
if (printcell.selcol >= 0)
selcellw = screencolwidth[printcell.selcol] + text_offset;
int maxw = vp_w - (sbwidth + selcellw + 1);
for (int i = printcell.selcol - 1; i >= 0; i--)
@ -304,7 +306,11 @@ static void printcell_listdraw_fn(struct list_putlineinfo_t *list_info)
if (selected_flag & SELECTED_FLAG)
{
if (printcell.selcol >= 0)
printcell.selcol_index = sidx[printcell.selcol]; /* save the item offset*/
else
printcell.selcol_index = -1;
cursor = Icon_Cursor;
/* limit length of selection if columns don't reach end */
int maxw = nx + printcell.totalcolw[screen] + printcell.iconw[screen];