Blame SOURCES/0004-jpeg-Do-not-use-next_output_byte-buf_empty_output_bu.patch

95e694
From 0605440f7344d9d6d1b047992fbadcd256f2c301 Mon Sep 17 00:00:00 2001
95e694
From: Frediano Ziglio <fziglio@redhat.com>
95e694
Date: Tue, 17 Jul 2018 16:24:06 +0100
95e694
Subject: [PATCH 4/4] jpeg: Do not use next_output_byte buf_empty_output_buffer
95e694
95e694
The pointer is not updated to the last byte used so using it
95e694
to compute the bytes written into the buffer we ignore some bytes
95e694
causing some image corruptions.
95e694
Note that also free_in_buffer is not updated to last written byte.
95e694
When buf_empty_output_buffer is called the buffer is full so use the
95e694
size of it instead of relying on next_output_byte or free_in_buffer.
95e694
95e694
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
95e694
Acked-by: Uri Lublin <uril@redhat.com>
95e694
---
95e694
 src/jpeg.cpp | 2 +-
95e694
 1 file changed, 1 insertion(+), 1 deletion(-)
95e694
95e694
diff --git a/src/jpeg.cpp b/src/jpeg.cpp
95e694
index ceee359..5f6d128 100644
95e694
--- a/src/jpeg.cpp
95e694
+++ b/src/jpeg.cpp
95e694
@@ -23,7 +23,7 @@ struct JpegBuffer: public jpeg_destination_mgr
95e694
 static boolean buf_empty_output_buffer(j_compress_ptr cinfo)
95e694
 {
95e694
     JpegBuffer *buf = (JpegBuffer *) cinfo->dest;
95e694
-    size_t size = buf->next_output_byte - &buf->buffer[0];
95e694
+    size_t size = buf->buffer.size();
95e694
     buf->buffer.resize(buf->buffer.capacity() * 2);
95e694
     buf->next_output_byte = &buf->buffer[0] + size;
95e694
     buf->free_in_buffer = buf->buffer.size() - size;
95e694
-- 
95e694
2.17.1
95e694