forked from len0rd/rockbox
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
This commit is contained in:
parent
dfd5d0684a
commit
6e664f49b1
1 changed files with 4 additions and 2 deletions
|
@ -135,7 +135,7 @@ static void lock_font_handle(int handle, bool lock)
|
||||||
|
|
||||||
void font_lock(int font_id, bool lock)
|
void font_lock(int font_id, bool lock)
|
||||||
{
|
{
|
||||||
if( font_id == FONT_SYSFIXED )
|
if( font_id < 0 || font_id >= MAXFONTS )
|
||||||
return;
|
return;
|
||||||
if( buflib_allocations[font_id] >= 0 )
|
if( buflib_allocations[font_id] >= 0 )
|
||||||
lock_font_handle(buflib_allocations[font_id], lock);
|
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)
|
const char* font_filename(int font_id)
|
||||||
{
|
{
|
||||||
|
if ( font_id < 0 || font_id >= MAXFONTS )
|
||||||
|
return NULL;
|
||||||
int handle = buflib_allocations[font_id];
|
int handle = buflib_allocations[font_id];
|
||||||
if (handle > 0)
|
if (handle > 0)
|
||||||
return core_get_name(handle);
|
return core_get_name(handle);
|
||||||
|
@ -582,7 +584,7 @@ int font_load(const char *path)
|
||||||
|
|
||||||
void font_unload(int font_id)
|
void font_unload(int font_id)
|
||||||
{
|
{
|
||||||
if ( font_id == FONT_SYSFIXED )
|
if ( font_id < 0 || font_id >= MAXFONTS )
|
||||||
return;
|
return;
|
||||||
int handle = buflib_allocations[font_id];
|
int handle = buflib_allocations[font_id];
|
||||||
if ( handle < 0 )
|
if ( handle < 0 )
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue