summaryrefslogtreecommitdiff
path: root/gdk-pixbuf
diff options
context:
space:
mode:
authorNathan Lee <utasstudent-git1271@yahoo.com>2020-02-15 07:04:46 +0000
committerEmmanuele Bassi <ebassi@gmail.com>2020-04-02 11:50:59 +0000
commit35dcd72bbe7a9349861ff14389a38525fe9c949f (patch)
tree5afd8bfeeec62631659ec148310f6ae722b9cf2e /gdk-pixbuf
parent37ab8e55bdd202fefc03448497b350a2469d6201 (diff)
downloadgdk-pixbuf-35dcd72bbe7a9349861ff14389a38525fe9c949f.tar.gz
JPEG: skip bytes during incremental load
Previously only skipped bytes at the start of incremental loads. During a incremental load, there may be bytes to skip between reloads. Previous behavior misread metadata sometimes. Fixes #70
Diffstat (limited to 'gdk-pixbuf')
-rw-r--r--gdk-pixbuf/io-jpeg.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/gdk-pixbuf/io-jpeg.c b/gdk-pixbuf/io-jpeg.c
index 7628989d9..ac6adbdf1 100644
--- a/gdk-pixbuf/io-jpeg.c
+++ b/gdk-pixbuf/io-jpeg.c
@@ -970,7 +970,7 @@ gdk_pixbuf__jpeg_image_load_lines (JpegProgContext *context,
* buf - new image data
* size - length of new image data
*
- * append image data onto inrecrementally built output image
+ * append image data onto incrementally built output image
*/
static gboolean
gdk_pixbuf__jpeg_image_load_increment (gpointer data,
@@ -1007,22 +1007,8 @@ gdk_pixbuf__jpeg_image_load_increment (gpointer data,
goto out;
}
- /* skip over data if requested, handle unsigned int sizes cleanly */
- /* only can happen if we've already called jpeg_get_header once */
- if (context->src_initialized && src->skip_next) {
- if (src->skip_next > size) {
- src->skip_next -= size;
- retval = TRUE;
- goto out;
- } else {
- num_left = size - src->skip_next;
- bufhd = buf + src->skip_next;
- src->skip_next = 0;
- }
- } else {
- num_left = size;
- bufhd = buf;
- }
+ num_left = size;
+ bufhd = buf;
if (num_left == 0) {
retval = TRUE;
@@ -1034,6 +1020,19 @@ gdk_pixbuf__jpeg_image_load_increment (gpointer data,
spinguard = 0;
first = TRUE;
while (TRUE) {
+ /* skip over data if requested, handle unsigned int sizes cleanly */
+ /* only can happen if we've already called jpeg_get_header */
+ if (context->src_initialized && src->skip_next) {
+ if (src->skip_next >= num_left) {
+ src->skip_next -= num_left;
+ retval = TRUE;
+ goto out;
+ } else {
+ num_left -= src->skip_next;
+ bufhd += src->skip_next;
+ src->skip_next = 0;
+ }
+ }
/* handle any data from caller we haven't processed yet */
if (num_left > 0) {