]> git.draconx.ca Git - liblbx.git/commitdiff
liblbx: Add a hard check for image leadin versus frame count.
authorNick Bowler <nbowler@draconx.ca>
Fri, 31 Jan 2014 03:17:43 +0000 (22:17 -0500)
committerNick Bowler <nbowler@draconx.ca>
Fri, 31 Jan 2014 05:39:01 +0000 (00:39 -0500)
Our "official" image spec says that the leadin is a frame number, so
it does not make sense for the leadin to be greater than or equal to
the frame count.

Convert the existing "soft" check into a hard failure.

src/image.c

index 27c82734bf853ec56742aefd9dbbe66295fa6ca6..adc6a43427289a20b581255abd70be6c1b3c908f 100644 (file)
@@ -93,6 +93,12 @@ static struct lbx_image_priv *lbx_img_init(unsigned char hdr[static HDR_LEN])
        if (img->flags & FLAG_LOOPING)
                img->pub.leadin = 0;
 
+       if (img->pub.leadin >= img->pub.frames) {
+               lbx_error_raise(LBX_EFORMAT);
+               free(img);
+               return NULL;
+       }
+
        return img;
 }
 
@@ -124,7 +130,6 @@ struct lbx_image *lbx_img_open(void *f, const struct lbx_file_ops *fops,
         */
        _lbx_assert(img->wtf  == 0); /* version? */
        _lbx_assert(img->wtf2 == 0); /* very likely is simply reserved. */
-       _lbx_assert(img->pub.frames > img->pub.leadin);
        _lbx_assert(!(img->flags & ~FLAG_ALL));
 
        /* Read all offsets.  Should be merged with identical code in lbx.c */