mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-10 03:19:40 +00:00
mpeg2: fix memory leak of empty packets.
Fix memory leakage of empty packets, i.e. packets that only contain the start code prefix. In particular, free empty user-data packets. Besides, the codec parser will already fail gracefully if the packet to parse does not have the minimum required size. So, we can also completely drop the block of code that used to handle packets of size 4 (including the start code).
This commit is contained in:
parent
8f7d19f010
commit
91da4fcb18
1 changed files with 1 additions and 12 deletions
|
@ -971,7 +971,7 @@ decode_buffer(GstVaapiDecoderMpeg2 *decoder, GstBuffer *buffer)
|
|||
}
|
||||
|
||||
status = GST_VAAPI_DECODER_STATUS_ERROR_NO_DATA;
|
||||
if (size < 8)
|
||||
if (size < 4)
|
||||
break;
|
||||
ofs = scan_for_start_code(priv->adapter, 0, size, &start_code);
|
||||
if (ofs < 0)
|
||||
|
@ -992,17 +992,6 @@ decode_buffer(GstVaapiDecoderMpeg2 *decoder, GstBuffer *buffer)
|
|||
buffer = gst_adapter_take_buffer(priv->adapter, ofs);
|
||||
size -= ofs;
|
||||
|
||||
if (ofs == 4) {
|
||||
// Ignore empty user-data packets
|
||||
if ((start_code & 0xff) == GST_MPEG_VIDEO_PACKET_USER_DATA) {
|
||||
status = GST_VAAPI_DECODER_STATUS_SUCCESS;
|
||||
continue;
|
||||
}
|
||||
GST_ERROR("failed to get a valid packet (SC: 0x%08x)", start_code);
|
||||
status = GST_VAAPI_DECODER_STATUS_ERROR_BITSTREAM_PARSER;
|
||||
break;
|
||||
}
|
||||
|
||||
buf = GST_BUFFER_DATA(buffer);
|
||||
buf_size = GST_BUFFER_SIZE(buffer);
|
||||
|
||||
|
|
Loading…
Reference in a new issue