gstcaps: fix out of bounds checks

These two checks could end up allowing out of bounds array access, when
the index equals the array size.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/445>
This commit is contained in:
Juan Navarro 2020-04-22 18:59:54 +02:00 committed by GStreamer Merge Bot
parent 166c0fbc47
commit 358d4e991a

View file

@ -708,7 +708,7 @@ gst_caps_remove_structure (GstCaps * caps, guint idx)
GstStructure *structure;
g_return_if_fail (caps != NULL);
g_return_if_fail (idx <= gst_caps_get_size (caps));
g_return_if_fail (idx < gst_caps_get_size (caps));
g_return_if_fail (IS_WRITABLE (caps));
structure = gst_caps_remove_and_get_structure (caps, idx);
@ -958,7 +958,7 @@ gst_caps_set_features (GstCaps * caps, guint index, GstCapsFeatures * features)
GstCapsFeatures **storage, *old;
g_return_if_fail (caps != NULL);
g_return_if_fail (index <= gst_caps_get_size (caps));
g_return_if_fail (index < gst_caps_get_size (caps));
g_return_if_fail (IS_WRITABLE (caps));
storage = gst_caps_get_features_storage_unchecked (caps, index);