diff options
author | William Wilgus <wilgus.william@gmail.com> | 2022-12-31 10:45:29 -0500 |
---|---|---|
committer | William Wilgus <me.theuser@yahoo.com> | 2022-12-31 16:12:18 -0500 |
commit | 0330aa8eb202c51b1fd7e9c45d94b683c1537f8d (patch) | |
tree | 95e20a71c5a2b8235d9357c7cae9d39ee1e94cc0 /apps/plugins | |
parent | 485e96d6beda16dc8b9ee74e7d10a957c3fddb2f (diff) | |
download | rockbox-0330aa8eb202c51b1fd7e9c45d94b683c1537f8d.tar.gz rockbox-0330aa8eb202c51b1fd7e9c45d94b683c1537f8d.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')
-rw-r--r-- | apps/plugins/lib/printcell_helper.c | 10 |
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 | |||
192 | uint16_t *screencolwidth = printcell.colw[screen]; | 192 | uint16_t *screencolwidth = printcell.colw[screen]; |
193 | int screenicnwidth = printcell.iconw[screen]; | 193 | int screenicnwidth = printcell.iconw[screen]; |
194 | int offset = 0; | 194 | int offset = 0; |
195 | int selcellw = screencolwidth[printcell.selcol] + text_offset; | 195 | int selcellw = 0; |
196 | if (printcell.selcol >= 0) | ||
197 | selcellw = screencolwidth[printcell.selcol] + text_offset; | ||
196 | int maxw = vp_w - (sbwidth + selcellw + 1); | 198 | int maxw = vp_w - (sbwidth + selcellw + 1); |
197 | 199 | ||
198 | for (int i = printcell.selcol - 1; i >= 0; i--) | 200 | for (int i = printcell.selcol - 1; i >= 0; i--) |
@@ -304,7 +306,11 @@ static void printcell_listdraw_fn(struct list_putlineinfo_t *list_info) | |||
304 | 306 | ||
305 | if (selected_flag & SELECTED_FLAG) | 307 | if (selected_flag & SELECTED_FLAG) |
306 | { | 308 | { |
307 | printcell.selcol_index = sidx[printcell.selcol]; /* save the item offset*/ | 309 | if (printcell.selcol >= 0) |
310 | printcell.selcol_index = sidx[printcell.selcol]; /* save the item offset*/ | ||
311 | else | ||
312 | printcell.selcol_index = -1; | ||
313 | |||
308 | cursor = Icon_Cursor; | 314 | cursor = Icon_Cursor; |
309 | /* limit length of selection if columns don't reach end */ | 315 | /* limit length of selection if columns don't reach end */ |
310 | int maxw = nx + printcell.totalcolw[screen] + printcell.iconw[screen]; | 316 | int maxw = nx + printcell.totalcolw[screen] + printcell.iconw[screen]; |