From 117ebdb28c74ca8c34e29f0450dcf06dcc0474c3 Mon Sep 17 00:00:00 2001 From: Fred Bauer Date: Tue, 27 Sep 2011 01:02:34 +0000 Subject: Do not move NULL pointers in buflibmove_callback(). Fixes some skin crashes when changing themes. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30610 a1c6a512-1295-4272-9138-f99709370657 --- firmware/font.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'firmware') diff --git a/firmware/font.c b/firmware/font.c index 2be90355db..e6f90e4ca5 100644 --- a/firmware/font.c +++ b/firmware/font.c @@ -93,8 +93,10 @@ static int buflibmove_callback(int handle, void* current, void* new) if (alloc->handle_locked) return BUFLIB_CB_CANNOT_MOVE; - alloc->font.bits += diff; - alloc->font.offset += diff; + if (alloc->font.bits) + alloc->font.bits += diff; + if (alloc->font.offset) + alloc->font.offset += diff; if (alloc->font.width) alloc->font.width += diff; @@ -102,8 +104,10 @@ static int buflibmove_callback(int handle, void* current, void* new) alloc->font.buffer_end += diff; alloc->font.buffer_position += diff; - alloc->font.cache._index += diff; - alloc->font.cache._lru._base += diff; + if (alloc->font.cache._index) + alloc->font.cache._index += diff; + if (alloc->font.cache._lru._base) + alloc->font.cache._lru._base += diff; return BUFLIB_CB_OK; } -- cgit v1.2.3