summaryrefslogtreecommitdiff
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
parentdfd5d0684a87b9d7d8b8a2055b061a4b6560adad (diff)
downloadrockbox-6e664f49b1aa60edf2e328b0df4d7e67e594184c.tar.gz
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
-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)
135 135
136void font_lock(int font_id, bool lock) 136void font_lock(int font_id, bool lock)
137{ 137{
138 if( font_id == FONT_SYSFIXED ) 138 if( font_id < 0 || font_id >= MAXFONTS )
139 return; 139 return;
140 if( buflib_allocations[font_id] >= 0 ) 140 if( buflib_allocations[font_id] >= 0 )
141 lock_font_handle(buflib_allocations[font_id], lock); 141 lock_font_handle(buflib_allocations[font_id], lock);
@@ -340,6 +340,8 @@ static int find_font_index(const char* path)
340 340
341const char* font_filename(int font_id) 341const char* font_filename(int font_id)
342{ 342{
343 if ( font_id < 0 || font_id >= MAXFONTS )
344 return NULL;
343 int handle = buflib_allocations[font_id]; 345 int handle = buflib_allocations[font_id];
344 if (handle > 0) 346 if (handle > 0)
345 return core_get_name(handle); 347 return core_get_name(handle);
@@ -582,7 +584,7 @@ int font_load(const char *path)
582 584
583void font_unload(int font_id) 585void font_unload(int font_id)
584{ 586{
585 if ( font_id == FONT_SYSFIXED ) 587 if ( font_id < 0 || font_id >= MAXFONTS )
586 return; 588 return;
587 int handle = buflib_allocations[font_id]; 589 int handle = buflib_allocations[font_id];
588 if ( handle < 0 ) 590 if ( handle < 0 )