From 0330aa8eb202c51b1fd7e9c45d94b683c1537f8d Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Sat, 31 Dec 2022 10:45:29 -0500 Subject: [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 --- apps/plugins/lib/printcell_helper.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'apps/plugins/lib') diff --git a/apps/plugins/lib/printcell_helper.c b/apps/plugins/lib/printcell_helper.c index f34636585e..42de444c57 100644 --- a/apps/plugins/lib/printcell_helper.c +++ b/apps/plugins/lib/printcell_helper.c @@ -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) { - printcell.selcol_index = sidx[printcell.selcol]; /* save the item offset*/ + 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]; -- cgit v1.2.3