]> git.draconx.ca Git - liblbx.git/blobdiff - src/image.c
Trivial manual fixes.
[liblbx.git] / src / image.c
index adc6a43427289a20b581255abd70be6c1b3c908f..ed80565439f65329875c831f200efd2645ec2213 100644 (file)
@@ -62,10 +62,10 @@ struct lbx_image_priv {
        unsigned currentx, currenty, currentn;
        int read_state;
 
-       unsigned long offsets[];
+       unsigned long offsets[FLEXIBLE_ARRAY_MEMBER];
 };
 
-static struct lbx_image_priv *lbx_img_init(unsigned char hdr[static HDR_LEN])
+static struct lbx_image_priv *lbx_img_init(unsigned char *hdr)
 {
        unsigned short nframes = unpack_16_le(hdr+6);
        struct lbx_image_priv *img;
@@ -313,11 +313,14 @@ long lbx_img_read_row_data(struct lbx_image *pub, void *buf)
                return -1;
        }
 
-       if (!(img->flags & FLAG_RAW)) {
-               /* Skip padding byte, if any */
-               if (img->currentn % 2) {
-                       if (img->fops->seek(img->f, 1, SEEK_CUR))
-                               return -1;
+       if (!(img->flags & FLAG_RAW) && img->currentn % 2) {
+               unsigned char c;
+
+               /* Skip padding byte */
+               if (img->fops->read(&c, 1, img->f) != 1) {
+                       if (img->fops->eof(img->f))
+                               lbx_error_raise(LBX_EEOF);
+                       return -1;
                }
        }