codecs: h265: Do not free slice header before using it
authorDetlev Casanova <detlev.casanova@collabora.com>
Tue, 17 Oct 2023 16:42:59 +0000 (12:42 -0400)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Wed, 18 Oct 2023 00:17:54 +0000 (00:17 +0000)
The v4l2codecs H.265 decoder uses the
GstH265SliceHdr::entry_point_offset_minus1 array so make sure that it is not
freed before decoding the frame.

Before this patch, some H.265 input would segfault in
gst_v4l2_codec_h265_dec_fill_slice_params() when executing the line:

guint32 entry_point_offset = slice_hdr->entry_point_offset_minus1[i] + 1;

Make sure that the array is not freed before using it.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5503>

subprojects/gst-plugins-bad/gst-libs/gst/codecs/gsth265decoder.c

index 70f0be9..70b5d77 100644 (file)
@@ -829,11 +829,6 @@ gst_h265_decoder_parse_slice (GstH265Decoder * self, GstH265NalUnit * nalu)
   if (pres != GST_H265_PARSER_OK)
     return pres;
 
-  /* NOTE: gst_h265_parser_parse_slice_hdr() allocates array
-   * GstH265SliceHdr::entry_point_offset_minus1 but we don't use it
-   * in this h265decoder baseclass at the moment
-   */
-  gst_h265_slice_hdr_free (&slice.header);
   slice.nalu = *nalu;
 
   if (nalu->type >= GST_H265_NAL_SLICE_BLA_W_LP &&
@@ -2049,6 +2044,9 @@ gst_h265_decoder_clear_nalu (GstH265DecoderNalUnit * nalu)
   if (!nalu)
     return;
 
+  if (nalu->is_slice)
+    gst_h265_slice_hdr_free (&nalu->unit.slice.header);
+
   memset (nalu, 0, sizeof (GstH265DecoderNalUnit));
 }