Index: apps/plugins/lib/read_image.c =================================================================== --- apps/plugins/lib/read_image.c (revision 22209) +++ apps/plugins/lib/read_image.c (working copy) @@ -39,14 +39,20 @@ int maxsize, int format, const struct custom_format *cformat) { + int ret = 0; int fd = rb->open(filename, O_RDONLY); if (fd < 0) return fd; - if (offset != rb->lseek(fd, offset, SEEK_SET)) + if (offset != rb->lseek(fd, offset, SEEK_SET)) { + rb->close(fd); return -1; + } int namelen = rb->strlen(filename); if (rb->strcmp(filename + namelen - 4, ".bmp")) - return read_jpeg_fd(fd, bm, maxsize, format, cformat); + ret = read_jpeg_fd(fd, bm, maxsize, format, cformat); else - return scaled_read_bmp_fd(fd, bm, maxsize, format, cformat); + ret = scaled_read_bmp_fd(fd, bm, maxsize, format, cformat); + rb->close(fd); + return ret; } +