Skip to content

Commit aa4448c

Browse files
committed
rtpjpegpay: fix image corruption when compiled with MSVC on Windows
On Windows with MSVC, jpeg_header_size would end up 2 bytes larger than it should be. This then leads to the first 2 bytes of the actual jpeg image data to be dropped, because we think those belong to the header, which results in an undecodable image when reconstructed in the depayloader. What happens is that when the compiler evaluates jpeg_header_size = mem.offset + read_u16_and_inc_offset_by_2(&mem); it actually uses the mem.offset value after it has been increased by the function call on the right hand size of the equation. From section 6.5 of the C99 spec: 3. The grouping of operators and operands is indicated by the syntax [74]. Except as specified later (for the function-call (), &&, ||, ?:, and comma operators), the order of evaluation of subexpressions and the order in which side effects take place are both unspecified. Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/issues/889 Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/999>
1 parent f4049fc commit aa4448c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

gst/rtp/gstrtpjpegpay.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -780,8 +780,9 @@ gst_rtp_jpeg_pay_handle_buffer (GstRTPBasePayload * basepayload,
780780
case JPEG_MARKER_SOS:
781781
sos_found = TRUE;
782782
GST_LOG_OBJECT (pay, "SOS found");
783-
jpeg_header_size =
784-
memory.offset + parse_mem_inc_offset_guint16 (&memory);
783+
jpeg_header_size = memory.offset;
784+
/* Do not re-combine into single statement with previous line! */
785+
jpeg_header_size += parse_mem_inc_offset_guint16 (&memory);
785786
break;
786787
case JPEG_MARKER_EOI:
787788
GST_WARNING_OBJECT (pay, "EOI reached before SOS!");

0 commit comments

Comments
 (0)