[Spice-devel] [spice-gtk 3/4] mjpeg: remove wrong g_return_if_fail

Christophe Fergeau cfergeau at redhat.com
Fri Jul 29 07:50:44 PDT 2011


After calling jpeg_read_scanlines, spice-gtk checks that we read
the amount of lines we expected, and if not, it returns early.
This is doubly wrong:

* jpeg_read_scanlines is documented as returning at most the number
of lines requested, but it also warns that an application shouldn't
rely on getting exactly the number of scanlines requested. In this
case, if rec_outbuf_height is bigger than 1, we'll get a short read
on the last line of odd-sized images, thus triggering the
g_return_if_fail

* returning from this function without calling jpeg_abort will cause
libjpeg to abort next time we use it because jpeg_start_decompress
was called before

This commit removes this check and early return.
---
 gtk/channel-display-mjpeg.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/gtk/channel-display-mjpeg.c b/gtk/channel-display-mjpeg.c
index 3789c87..9e8bc0b 100644
--- a/gtk/channel-display-mjpeg.c
+++ b/gtk/channel-display-mjpeg.c
@@ -116,8 +116,6 @@ void stream_mjpeg_data(display_stream *st)
         }
         lines_read = jpeg_read_scanlines(&st->mjpeg_cinfo, lines,
                                 st->mjpeg_cinfo.rec_outbuf_height);
-        // this shouldn't happen either..
-        g_return_if_fail(lines_read == st->mjpeg_cinfo.rec_outbuf_height);
 #ifndef JCS_EXTENSIONS
         {
             uint8_t *s = lines[0];
-- 
1.7.6



More information about the Spice-devel mailing list