summaryrefslogtreecommitdiffstats
path: root/apps/plugins/lib/printcell_helper.c
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2022-12-31 10:45:29 -0500
committerWilliam Wilgus <me.theuser@yahoo.com>2022-12-31 16:12:18 -0500
commit0330aa8eb202c51b1fd7e9c45d94b683c1537f8d (patch)
tree95e20a71c5a2b8235d9357c7cae9d39ee1e94cc0 /apps/plugins/lib/printcell_helper.c
parent485e96d6beda16dc8b9ee74e7d10a957c3fddb2f (diff)
downloadrockbox-0330aa8eb2.tar.gz
rockbox-0330aa8eb2.zip
[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
Diffstat (limited to 'apps/plugins/lib/printcell_helper.c')
-rw-r--r--apps/plugins/lib/printcell_helper.c10
1 files changed, 8 insertions, 2 deletions
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];