video-anc: Add invalid-argument guards to public GstVideoVBIParser API

This commit is contained in:
Sebastian Dröge 2018-11-07 13:58:17 +02:00 committed by Nicolas Dufresne
parent 11b9695b88
commit eac38b47d4

View File

@ -34,7 +34,6 @@
* present in Vertical Blanking Interval as well as Closed Caption. * present in Vertical Blanking Interval as well as Closed Caption.
*/ */
#ifndef GST_DISABLE_GST_DEBUG #ifndef GST_DISABLE_GST_DEBUG
#define GST_CAT_DEFAULT ensure_debug_category() #define GST_CAT_DEFAULT ensure_debug_category()
static GstDebugCategory * static GstDebugCategory *
@ -75,6 +74,8 @@ gst_video_vbi_parser_copy (const GstVideoVBIParser * parser)
{ {
GstVideoVBIParser *res; GstVideoVBIParser *res;
g_return_val_if_fail (parser != NULL, NULL);
res = gst_video_vbi_parser_new (GST_VIDEO_INFO_FORMAT (&parser->info), res = gst_video_vbi_parser_new (GST_VIDEO_INFO_FORMAT (&parser->info),
parser->info.width); parser->info.width);
if (res) { if (res) {
@ -219,6 +220,9 @@ GstVideoVBIParserResult
gst_video_vbi_parser_get_ancillary (GstVideoVBIParser * parser, gst_video_vbi_parser_get_ancillary (GstVideoVBIParser * parser,
GstVideoAncillary * anc) GstVideoAncillary * anc)
{ {
g_return_val_if_fail (parser != NULL, GST_VIDEO_VBI_PARSER_RESULT_ERROR);
g_return_val_if_fail (anc != NULL, GST_VIDEO_VBI_PARSER_RESULT_ERROR);
if (parser->bit16) if (parser->bit16)
return get_ancillary_16 (parser, anc); return get_ancillary_16 (parser, anc);
return get_ancillary_8 (parser, anc); return get_ancillary_8 (parser, anc);
@ -241,6 +245,8 @@ gst_video_vbi_parser_new (GstVideoFormat format, guint32 pixel_width)
{ {
GstVideoVBIParser *parser; GstVideoVBIParser *parser;
g_return_val_if_fail (pixel_width > 0, NULL);
switch (format) { switch (format) {
case GST_VIDEO_FORMAT_v210: case GST_VIDEO_FORMAT_v210:
parser = g_new0 (GstVideoVBIParser, 1); parser = g_new0 (GstVideoVBIParser, 1);
@ -287,11 +293,12 @@ gst_video_vbi_parser_new (GstVideoFormat format, guint32 pixel_width)
void void
gst_video_vbi_parser_free (GstVideoVBIParser * parser) gst_video_vbi_parser_free (GstVideoVBIParser * parser)
{ {
g_return_if_fail (parser != NULL);
g_free (parser->work_data); g_free (parser->work_data);
g_free (parser); g_free (parser);
} }
static void static void
convert_line_uyvy (GstVideoVBIParser * parser, const guint8 * data) convert_line_uyvy (GstVideoVBIParser * parser, const guint8 * data)
{ {
@ -399,6 +406,9 @@ convert_line_v210 (GstVideoVBIParser * parser, const guint8 * data)
void void
gst_video_vbi_parser_add_line (GstVideoVBIParser * parser, const guint8 * data) gst_video_vbi_parser_add_line (GstVideoVBIParser * parser, const guint8 * data)
{ {
g_return_if_fail (parser != NULL);
g_return_if_fail (data != NULL);
/* Reset offset */ /* Reset offset */
parser->offset = 0; parser->offset = 0;