static boolean tag_fill_input_buffer(struct jpeg_decompress_struct *cinfo)
{
TAG *tag = (TAG *) cinfo->client_data;
- if (tag->data[tag->pos + 0] == 0xff &&
+ if (tag->pos + 4 <= tag->len &&
+ tag->data[tag->pos + 0] == 0xff &&
tag->data[tag->pos + 1] == 0xd9 &&
tag->data[tag->pos + 2] == 0xff &&
tag->data[tag->pos + 3] == 0xd8) {
int has_alpha = swf_ImageHasAlpha(mem,width,height);
/* try lossless image */
+
+#ifdef NO_LOSSLESS
+ tag1 = swf_InsertTag(0, /*ST_DEFINEBITSLOSSLESS1/2*/0);
+ tag1->len = 0x7fffffff;
+#else
tag1 = swf_InsertTag(0, /*ST_DEFINEBITSLOSSLESS1/2*/0);
swf_SetU16(tag1, bitid);
swf_SetLosslessImage(tag1, mem, width, height);
+#endif
#if defined(HAVE_JPEGLIB)
/* try jpeg image */