Backport r31075 to avoid freezes on invalid font ids

git-svn-id: svn://svn.rockbox.org/rockbox/branches/v3_10@31076 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Frank Gevaerts 2011-11-27 15:39:33 +00:00
parent cc16c1070a
commit 5bc2945fde

View file

@ -127,7 +127,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);
@ -484,6 +484,8 @@ static int alloc_and_init(int font_idx, const char* name, size_t size)
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);
@ -578,7 +580,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 )