summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2024-06-02 10:32:47 -0400
committerWilliam Wilgus <wilgus.william@gmail.com>2024-06-02 10:32:47 -0400
commitcc67f420f215481ef41ed2bc228fb2b28f7eeb80 (patch)
treef266481bb6d40dfca116a3810d58309a00379cfb
parent5d34887d4ac3c3a2fcd6827f3ca70def65336591 (diff)
downloadrockbox-cc67f420f2.tar.gz
rockbox-cc67f420f2.zip
[coverity] font.c load_cache_entry check for successful read
Change-Id: Ic2d8d6e498417983af7ee691f53dfb1e951561fa
-rw-r--r--firmware/font.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/firmware/font.c b/firmware/font.c
index baaec13d3c..ffa5855d10 100644
--- a/firmware/font.c
+++ b/firmware/font.c
@@ -724,7 +724,6 @@ load_cache_entry(struct font_cache_entry* p, void* callback_data)
struct font* pf = callback_data;
unsigned short char_code = p->_char_code;
- unsigned char tmp[2];
int fd;
lock_font_handle(pf->handle, true);
@@ -755,11 +754,14 @@ load_cache_entry(struct font_cache_entry* p, void* callback_data)
else
fd = pf->fd;
lseek(fd, offset, SEEK_SET);
- read (fd, tmp, 2);
- bitmap_offset = tmp[0] | (tmp[1] << 8);
- if (pf->long_offset) {
- read (fd, tmp, 2);
- bitmap_offset |= (tmp[0] << 16) | (tmp[1] << 24);
+ unsigned char tmp[2];
+ if (read (fd, tmp, 2) == 2)
+ {
+ bitmap_offset = tmp[0] | (tmp[1] << 8);
+ if (pf->long_offset) {
+ if (read (fd, tmp, 2) == 2)
+ bitmap_offset |= (tmp[0] << 16) | (tmp[1] << 24);
+ }
}
}
else