codecparsers: h264parser: guard against ref_pic_markings overflow
authorAndrew Wesie <andrew@theori.io>
Fri, 16 Oct 2020 11:29:02 +0000 (12:29 +0100)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Fri, 16 Oct 2020 15:11:26 +0000 (15:11 +0000)
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1703>

gst-libs/gst/codecparsers/gsth264parser.c

index 1c40b6517c402ca48a82456aea6f697a3009c55f..012f1d0d731779be965a5627176c143cd39738b2 100644 (file)
@@ -723,13 +723,17 @@ gst_h264_slice_parse_dec_ref_pic_marking (GstH264SliceHdr * slice,
 
       dec_ref_pic_m->n_ref_pic_marking = 0;
       while (1) {
-        refpicmarking =
-            &dec_ref_pic_m->ref_pic_marking[dec_ref_pic_m->n_ref_pic_marking];
-
         READ_UE (nr, mem_mgmt_ctrl_op);
         if (mem_mgmt_ctrl_op == 0)
           break;
 
+        if (dec_ref_pic_m->n_ref_pic_marking >=
+            G_N_ELEMENTS (dec_ref_pic_m->ref_pic_marking))
+          goto error;
+
+        refpicmarking =
+            &dec_ref_pic_m->ref_pic_marking[dec_ref_pic_m->n_ref_pic_marking];
+
         refpicmarking->memory_management_control_operation = mem_mgmt_ctrl_op;
 
         if (mem_mgmt_ctrl_op == 1 || mem_mgmt_ctrl_op == 3)