From 29d0db83b8341e50c1365d8fc1569d33b78264aa Mon Sep 17 00:00:00 2001 From: raster Date: Fri, 19 Aug 2011 06:58:33 +0000 Subject: [PATCH] fix buffer over/underflow errors with jpeg mmap load. ugh. mmap adds pains to loading. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@62584 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/modules/loaders/jpeg/evas_image_load_jpeg.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/modules/loaders/jpeg/evas_image_load_jpeg.c b/src/modules/loaders/jpeg/evas_image_load_jpeg.c index 9f88d1f..34840cb 100644 --- a/src/modules/loaders/jpeg/evas_image_load_jpeg.c +++ b/src/modules/loaders/jpeg/evas_image_load_jpeg.c @@ -111,22 +111,18 @@ _evas_jpeg_membuf_src_fill(j_decompress_ptr cinfo) static void _evas_jpeg_membuf_src_skip(j_decompress_ptr cinfo, - long num_bytes) + long num_bytes) { struct jpeg_membuf_src *src = (struct jpeg_membuf_src *)cinfo->src; - long rec = 0; - rec = src->pub.bytes_in_buffer - num_bytes; - - if (rec <0) + if ((((long)src->pub.bytes_in_buffer - (long)src->len) > num_bytes) || + ((long)src->pub.bytes_in_buffer < num_bytes)) { (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)); + return; } - else - { - src->pub.bytes_in_buffer -= num_bytes; - src->pub.next_input_byte += num_bytes; - } + src->pub.bytes_in_buffer -= num_bytes; + src->pub.next_input_byte += num_bytes; } static void -- 2.7.4