summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorNicolas Pennequin <nicolas.pennequin@free.fr>2007-11-12 15:16:41 +0000
committerNicolas Pennequin <nicolas.pennequin@free.fr>2007-11-12 15:16:41 +0000
commit87e5b1193cf858e2204970b6cce36eb50fefd934 (patch)
treed23bab8400118beabfe840b8e57e431fdf001b34 /apps
parent1480d078e7d6c55e91a60050f1f943468c6fe89c (diff)
downloadrockbox-87e5b1193cf858e2204970b6cce36eb50fefd934.zip
rockbox-87e5b1193cf858e2204970b6cce36eb50fefd934.tar.gz
rockbox-87e5b1193cf858e2204970b6cce36eb50fefd934.tar.bz2
rockbox-87e5b1193cf858e2204970b6cce36eb50fefd934.tar.xz
The error checking for bitmap handling in bufopen was serioulsy broken, as loading a huge bitmap showed. Fix it and reorganise the code slightly.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15597 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/buffering.c33
1 files changed, 21 insertions, 12 deletions
diff --git a/apps/buffering.c b/apps/buffering.c
index 4176f27..fd386fd 100644
--- a/apps/buffering.c
+++ b/apps/buffering.c
@@ -884,31 +884,40 @@ int bufopen(const char *file, size_t offset, enum data_type type)
}
strncpy(h->path, file, MAX_PATH);
- h->filerem = size - offset;
h->offset = offset;
h->ridx = buf_widx;
- h->widx = buf_widx;
h->data = buf_widx;
- h->available = 0;
h->type = type;
#ifdef HAVE_ALBUMART
- if (type == TYPE_BITMAP) {
+ if (type == TYPE_BITMAP)
+ {
/* Bitmap file: we load the data instead of the file */
+ int rc;
mutex_lock(&llist_mutex); /* Lock because load_bitmap yields */
- size = load_bitmap(fd);
- if (size <= 0)
+ rc = load_bitmap(fd);
+ if (rc <= 0)
+ {
+ rm_handle(h);
+ close(fd);
+ mutex_unlock(&llist_mutex);
return ERR_FILE_ERROR;
-
+ }
h->filerem = 0;
- h->available = size;
- h->widx = buf_widx + size; /* safe because the data doesn't wrap */
- buf_widx += size; /* safe too */
+ h->filesize = rc;
+ h->available = rc;
+ h->widx = buf_widx + rc; /* safe because the data doesn't wrap */
+ buf_widx += rc; /* safe too */
mutex_unlock(&llist_mutex);
}
+ else
#endif
-
- h->filesize = size;
+ {
+ h->filerem = size - offset;
+ h->filesize = size;
+ h->available = 0;
+ h->widx = buf_widx;
+ }
if (type == TYPE_CUESHEET) {
h->fd = fd;