summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorRoman Artiukhin <bahusdrive@gmail.com>2024-10-29 09:40:17 +0200
committerRoman Artiukhin <bahusdrive@gmail.com>2024-10-29 09:44:06 +0200
commit914a56f34c590d3872e5c41ce9fff65b637c49b4 (patch)
tree1ec2538ebb34665fd664f0b6f508fcee97185263 /apps
parentbd02af3413868c5aa343bb9f9c757611087e369c (diff)
downloadrockbox-914a56f34c590d3872e5c41ce9fff65b637c49b4.tar.gz
rockbox-914a56f34c590d3872e5c41ce9fff65b637c49b4.zip
imageviewer: fix segfault when album art fails to load
Attempt to change file fails due to access to uninitialized memory with negative index Fixup for 55a5bfe7 Change-Id: I9c42f66c856c1d4b7261da5e4996efbe9597bcd4
Diffstat (limited to 'apps')
-rw-r--r--apps/plugins/imageviewer/imageviewer.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/apps/plugins/imageviewer/imageviewer.c b/apps/plugins/imageviewer/imageviewer.c
index 77286bd37d..3ae4220721 100644
--- a/apps/plugins/imageviewer/imageviewer.c
+++ b/apps/plugins/imageviewer/imageviewer.c
@@ -136,15 +136,24 @@ static enum image_type image_type = IMAGE_UNKNOWN;
136/************************* Implementation ***************************/ 136/************************* Implementation ***************************/
137 137
138/* Read directory contents for scrolling. */ 138/* Read directory contents for scrolling. */
139static void get_pic_list(void) 139static void get_pic_list(bool single_file)
140{ 140{
141 file_pt = (char **) buf;
142
143 if (single_file)
144 {
145 file_pt[0] = np_file;
146 buf_size -= sizeof(file_pt);
147 entries = 1;
148 curfile = 0;
149 return;
150 }
151
141 struct tree_context *tree = rb->tree_get_context(); 152 struct tree_context *tree = rb->tree_get_context();
142 struct entry *dircache = rb->tree_get_entries(tree); 153 struct entry *dircache = rb->tree_get_entries(tree);
143 int i; 154 int i;
144 char *pname; 155 char *pname;
145 156
146 file_pt = (char **) buf;
147
148 /* Remove path and leave only the name.*/ 157 /* Remove path and leave only the name.*/
149 pname = rb->strrchr(np_file,'/'); 158 pname = rb->strrchr(np_file,'/');
150 pname++; 159 pname++;
@@ -1093,7 +1102,6 @@ enum plugin_status plugin_start(const void* parameter)
1093 return PLUGIN_ERROR; 1102 return PLUGIN_ERROR;
1094 } 1103 }
1095 1104
1096 entries = 1;
1097 is_album_art = true; 1105 is_album_art = true;
1098 } 1106 }
1099 else 1107 else
@@ -1112,11 +1120,7 @@ enum plugin_status plugin_start(const void* parameter)
1112 decoder_buf = rb->plugin_get_buffer(&decoder_buf_size); 1120 decoder_buf = rb->plugin_get_buffer(&decoder_buf_size);
1113 buf = rb->plugin_get_audio_buffer(&buf_size); 1121 buf = rb->plugin_get_audio_buffer(&buf_size);
1114#endif 1122#endif
1115 1123 get_pic_list(is_album_art);
1116 if(!is_album_art)
1117 {
1118 get_pic_list();
1119 }
1120 1124
1121#ifdef USEGSLIB 1125#ifdef USEGSLIB
1122 if (!grey_init(buf, buf_size, GREY_ON_COP, 1126 if (!grey_init(buf, buf_size, GREY_ON_COP,