From d023bf0f5dedb67caf9229e3ddcbb5a9fea420ce Mon Sep 17 00:00:00 2001 From: Bertrik Sikken Date: Sun, 10 Jun 2012 17:15:47 +0200 Subject: Fix checks on buflib allocated handles (0 is not a valid handle value) Change-Id: I8fdc5a59a5062f40a431cd49971390e21631b8ec --- apps/filetypes.c | 2 +- apps/gui/icon.c | 2 +- apps/gui/skin_engine/skin_backdrops.c | 2 +- apps/gui/skin_engine/skin_parser.c | 4 ++-- apps/scrobbler.c | 2 +- firmware/font.c | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/filetypes.c b/apps/filetypes.c index 49196d40ed..b765e7a3b0 100644 --- a/apps/filetypes.c +++ b/apps/filetypes.c @@ -344,7 +344,7 @@ void filetype_init(void) strdup_bufsize = filesize(fd); strdup_handle = core_alloc_ex("filetypes", strdup_bufsize, &ops); - if (strdup_handle < 0) + if (strdup_handle <= 0) { close(fd); return; diff --git a/apps/gui/icon.c b/apps/gui/icon.c index 46da38b765..f37cee969c 100644 --- a/apps/gui/icon.c +++ b/apps/gui/icon.c @@ -197,7 +197,7 @@ static void load_icons(const char* filename, enum Iconset iconset, size_t buf_size = read_bmp_fd(fd, &ic->bmp, 0, bmpformat|FORMAT_RETURN_SIZE, NULL); ic->handle = core_alloc_ex(filename, buf_size, &buflib_ops); - if (ic->handle < 0) + if (ic->handle <= 0) { close(fd); return; diff --git a/apps/gui/skin_engine/skin_backdrops.c b/apps/gui/skin_engine/skin_backdrops.c index edb895c56f..0d3c8b605f 100644 --- a/apps/gui/skin_engine/skin_backdrops.c +++ b/apps/gui/skin_engine/skin_backdrops.c @@ -245,7 +245,7 @@ void skin_backdrop_load_setting(void) backdrops[i].buflib_handle = core_alloc_ex(global_settings.backdrop_file, LCD_BACKDROP_BYTES, &buflib_ops); - if (backdrops[i].buflib_handle < 0) + if (backdrops[i].buflib_handle <= 0) return; } bool loaded; diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index 4784039a87..4de0aae3b2 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c @@ -1665,7 +1665,7 @@ static int load_skin_bmp(struct wps_data *wps_data, struct bitmap *bitmap, char* size_t buf_size = read_bmp_fd(fd, bitmap, 0, format|FORMAT_RETURN_SIZE, NULL); handle = core_alloc_ex(bitmap->data, buf_size, &buflib_ops); - if (handle < 0) + if (handle <= 0) { DEBUGF("Not enough skin buffer: need %zd more.\n", buf_size - skin_buffer_freespace()); @@ -2315,7 +2315,7 @@ bool skin_data_load(enum screen_type screen, struct wps_data *wps_data, #ifndef __PCTOOL__ wps_data->buflib_handle = core_alloc(isfile ? buf : "failsafe skin", skin_buffer_usage()); - if (wps_data->buflib_handle >= 0) + if (wps_data->buflib_handle > 0) { wps_data->wps_loaded = true; memcpy(core_get_data(wps_data->buflib_handle), skin_buffer, diff --git a/apps/scrobbler.c b/apps/scrobbler.c index 06c957cd6c..78414f3d88 100644 --- a/apps/scrobbler.c +++ b/apps/scrobbler.c @@ -255,7 +255,7 @@ int scrobbler_init(void) return -1; scrobbler_cache = core_alloc("scrobbler", SCROBBLER_MAX_CACHE*SCROBBLER_CACHE_LEN); - if (scrobbler_cache < 0) + if (scrobbler_cache <= 0) { logf("SCROOBLER: OOM"); return -1; diff --git a/firmware/font.c b/firmware/font.c index 4b21f0ffe3..06f104054f 100644 --- a/firmware/font.c +++ b/firmware/font.c @@ -514,7 +514,7 @@ int font_load_ex( const char *path, size_t buf_size, int glyphs ) int handle = core_alloc_ex( path, bufsize + sizeof( struct buflib_alloc_data ), &buflibops ); - if ( handle < 0 ) + if ( handle <= 0 ) { return -1; } -- cgit v1.2.3