video: Fix possible overrun when iterating comp[] array

Fix 2 iterations that can overrun the array if the number of component is
equal to the size of the array.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2239>
This commit is contained in:
Nicolas Dufresne 2022-04-19 11:05:05 -04:00
parent e0ad0eda23
commit b7ded51382
2 changed files with 2 additions and 2 deletions

View file

@ -7743,7 +7743,7 @@ gst_video_format_info_extrapolate_stride (const GstVideoFormatInfo * finfo,
* number of component on the first plane against the number of component on
* the current plane. */
estride = 0;
for (i = 0; comp[i] >= 0; i++)
for (i = 0; i < GST_VIDEO_MAX_COMPONENTS && comp[i] >= 0; i++)
estride += GST_VIDEO_FORMAT_INFO_SCALE_WIDTH (finfo, comp[i], stride);
return estride;

View file

@ -294,7 +294,7 @@ scale_tile_shifts (const GstVideoFormatInfo * finfo, gint plane, guint * ws,
/* for each additional component in the same plane, double the tile width,
* this should provide the appropriate tile size when the tile size varies
* base on the subsampling. */
for (i = 1; comp[i] >= 0; i++)
for (i = 1; i < GST_VIDEO_MAX_COMPONENTS && comp[i] >= 0; i++)
*ws += 1;
}