summaryrefslogtreecommitdiffstats
path: root/firmware/font.c
diff options
context:
space:
mode:
authorFrank Gevaerts <frank@gevaerts.be>2011-11-27 15:36:03 +0000
committerFrank Gevaerts <frank@gevaerts.be>2011-11-27 15:36:03 +0000
commit6e664f49b1aa60edf2e328b0df4d7e67e594184c (patch)
tree6bf51cc51241eb375885066801bc0be70fcb5888 /firmware/font.c
parentdfd5d0684a87b9d7d8b8a2055b061a4b6560adad (diff)
downloadrockbox-6e664f49b1aa60edf2e328b0df4d7e67e594184c.tar.gz
rockbox-6e664f49b1aa60edf2e328b0df4d7e67e594184c.tar.bz2
rockbox-6e664f49b1aa60edf2e328b0df4d7e67e594184c.zip
Guard font functions against invalid font ids. These arguably should never be passed, but this prevents freezes. Fixes FS#12400
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31075 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/font.c')
-rw-r--r--firmware/font.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/firmware/font.c b/firmware/font.c
index d8f8c59e0d..2b86d338db 100644
--- a/firmware/font.c
+++ b/firmware/font.c
@@ -135,7 +135,7 @@ static void lock_font_handle(int handle, bool lock)
void font_lock(int font_id, bool lock)
{
- if( font_id == FONT_SYSFIXED )
+ if( font_id < 0 || font_id >= MAXFONTS )
return;
if( buflib_allocations[font_id] >= 0 )
lock_font_handle(buflib_allocations[font_id], lock);
@@ -340,6 +340,8 @@ static int find_font_index(const char* path)
const char* font_filename(int font_id)
{
+ if ( font_id < 0 || font_id >= MAXFONTS )
+ return NULL;
int handle = buflib_allocations[font_id];
if (handle > 0)
return core_get_name(handle);
@@ -582,7 +584,7 @@ int font_load(const char *path)
void font_unload(int font_id)
{
- if ( font_id == FONT_SYSFIXED )
+ if ( font_id < 0 || font_id >= MAXFONTS )
return;
int handle = buflib_allocations[font_id];
if ( handle < 0 )