diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2016-11-23 20:10:34 +0200 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2016-11-24 15:06:39 +0200 |
commit | 681d97aed7a9a4e4804963a8e174d2daa7f96938 (patch) | |
tree | de2abd72bfa13a2adc4e03ac64e1b4e9b2ed8d4a | |
parent | 17cdd369e6f2f73329d27dfceb50011f40f1ceb0 (diff) |
video: Handle errors in gst_video_info_set_format() / gst_video_info_align()
https://bugzilla.gnome.org/show_bug.cgi?id=774588
-rw-r--r-- | gst-libs/gst/video/gstvideodecoder.c | 7 | ||||
-rw-r--r-- | gst-libs/gst/video/gstvideoencoder.c | 8 | ||||
-rw-r--r-- | gst-libs/gst/video/gstvideometa.c | 3 | ||||
-rw-r--r-- | gst-libs/gst/video/gstvideopool.c | 10 | ||||
-rw-r--r-- | gst-libs/gst/video/video-blend.c | 11 | ||||
-rw-r--r-- | gst-libs/gst/video/video-overlay-composition.c | 10 |
6 files changed, 38 insertions, 11 deletions
diff --git a/gst-libs/gst/video/gstvideodecoder.c b/gst-libs/gst/video/gstvideodecoder.c index 0fdf1c570..28a9f4930 100644 --- a/gst-libs/gst/video/gstvideodecoder.c +++ b/gst-libs/gst/video/gstvideodecoder.c @@ -640,7 +640,10 @@ _new_output_state (GstVideoFormat fmt, guint width, guint height, state = g_slice_new0 (GstVideoCodecState); state->ref_count = 1; gst_video_info_init (&state->info); - gst_video_info_set_format (&state->info, fmt, width, height); + if (!gst_video_info_set_format (&state->info, fmt, width, height)) { + g_slice_free (GstVideoCodecState, state); + return NULL; + } if (reference) { GstVideoInfo *tgt, *ref; @@ -3466,6 +3469,8 @@ gst_video_decoder_set_output_state (GstVideoDecoder * decoder, /* Create the new output state */ state = _new_output_state (fmt, width, height, reference); + if (!state) + return NULL; GST_VIDEO_DECODER_STREAM_LOCK (decoder); diff --git a/gst-libs/gst/video/gstvideoencoder.c b/gst-libs/gst/video/gstvideoencoder.c index 3622b0a71..6164a466d 100644 --- a/gst-libs/gst/video/gstvideoencoder.c +++ b/gst-libs/gst/video/gstvideoencoder.c @@ -517,7 +517,11 @@ _new_output_state (GstCaps * caps, GstVideoCodecState * reference) state = g_slice_new0 (GstVideoCodecState); state->ref_count = 1; gst_video_info_init (&state->info); - gst_video_info_set_format (&state->info, GST_VIDEO_FORMAT_ENCODED, 0, 0); + + if (!gst_video_info_set_format (&state->info, GST_VIDEO_FORMAT_ENCODED, 0, 0)) { + g_slice_free (GstVideoCodecState, state); + return NULL; + } state->caps = caps; @@ -2275,6 +2279,8 @@ gst_video_encoder_set_output_state (GstVideoEncoder * encoder, GstCaps * caps, g_return_val_if_fail (caps != NULL, NULL); state = _new_output_state (caps, reference); + if (!state) + return NULL; GST_VIDEO_ENCODER_STREAM_LOCK (encoder); if (priv->output_state) diff --git a/gst-libs/gst/video/gstvideometa.c b/gst-libs/gst/video/gstvideometa.c index fd5827b60..e2065d86c 100644 --- a/gst-libs/gst/video/gstvideometa.c +++ b/gst-libs/gst/video/gstvideometa.c @@ -270,7 +270,8 @@ gst_buffer_add_video_meta (GstBuffer * buffer, GstVideoMeta *meta; GstVideoInfo info; - gst_video_info_set_format (&info, format, width, height); + if (!gst_video_info_set_format (&info, format, width, height)) + return NULL; meta = gst_buffer_add_video_meta_full (buffer, flags, format, width, diff --git a/gst-libs/gst/video/gstvideopool.c b/gst-libs/gst/video/gstvideopool.c index f2ef276bd..99d122a72 100644 --- a/gst-libs/gst/video/gstvideopool.c +++ b/gst-libs/gst/video/gstvideopool.c @@ -186,7 +186,9 @@ video_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config) priv->video_align.stride_align[n] = max_align; /* apply the alignment to the info */ - gst_video_info_align (&info, &priv->video_align); + if (!gst_video_info_align (&info, &priv->video_align)) + goto failed_to_align; + gst_buffer_pool_config_set_video_alignment (config, &priv->video_align); if (priv->params.align < max_align) { @@ -227,7 +229,11 @@ wrong_size: GST_WARNING_OBJECT (pool, "Provided size is to small for the caps: %u", size); return FALSE; - + } +failed_to_align: + { + GST_WARNING_OBJECT (pool, "Failed to align"); + return FALSE; } } diff --git a/gst-libs/gst/video/video-blend.c b/gst-libs/gst/video/video-blend.c index 138a31475..fb7e00c47 100644 --- a/gst-libs/gst/video/video-blend.c +++ b/gst-libs/gst/video/video-blend.c @@ -175,11 +175,14 @@ gst_video_blend_scale_linear_RGBA (GstVideoInfo * src, GstBuffer * src_buffer, g_return_if_fail (dest_buffer != NULL); - tmpbuf = g_malloc (dest_width * 8 * 4); - gst_video_info_init (dest); - gst_video_info_set_format (dest, GST_VIDEO_INFO_FORMAT (src), - dest_width, dest_height); + if (!gst_video_info_set_format (dest, GST_VIDEO_INFO_FORMAT (src), + dest_width, dest_height)) { + g_warn_if_reached (); + return; + } + + tmpbuf = g_malloc (dest_width * 8 * 4); *dest_buffer = gst_buffer_new_and_alloc (GST_VIDEO_INFO_SIZE (dest)); diff --git a/gst-libs/gst/video/video-overlay-composition.c b/gst-libs/gst/video/video-overlay-composition.c index eba0fd845..7ed9ce6fe 100644 --- a/gst-libs/gst/video/video-overlay-composition.c +++ b/gst-libs/gst/video/video-overlay-composition.c @@ -739,7 +739,10 @@ gst_video_overlay_rectangle_new_raw (GstBuffer * pixels, rect->scaled_rectangles = NULL; gst_video_info_init (&rect->info); - gst_video_info_set_format (&rect->info, format, width, height); + if (!gst_video_info_set_format (&rect->info, format, width, height)) { + gst_mini_object_unref (GST_MINI_OBJECT_CAST (rect)); + return NULL; + } if (flags & GST_VIDEO_OVERLAY_FORMAT_FLAG_PREMULTIPLIED_ALPHA) rect->info.flags |= GST_VIDEO_FLAG_PREMULTIPLIED_ALPHA; @@ -1059,7 +1062,10 @@ gst_video_overlay_rectangle_convert (GstVideoInfo * src, GstBuffer * src_buffer, height = GST_VIDEO_INFO_HEIGHT (src); gst_video_info_init (dest); - gst_video_info_set_format (dest, dest_format, width, height); + if (!gst_video_info_set_format (dest, dest_format, width, height)) { + g_warn_if_reached (); + return; + } *dest_buffer = gst_buffer_new_and_alloc (GST_VIDEO_INFO_SIZE (dest)); |