From c7853c7629856648c2795cf3fd648147dc0512da Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 27 Jul 2006 11:00:21 +0000 Subject: [PATCH] gst/gstcaps.c: Fix useless assert, a uint is always positive. Original commit message from CVS: * gst/gstcaps.c: (gst_static_caps_get), (gst_caps_get_structure): Fix useless assert, a uint is always positive. * gst/gststructure.c: (gst_structure_nth_field_name), (gst_structure_foreach), (gst_structure_map_in_place): Check input arguments for public functions to avoid obvious crashes. * plugins/elements/gstfakesink.c: (gst_fake_sink_render): * plugins/elements/gstfakesink.h: Do less useless typechecking. --- ChangeLog | 13 +++++++++++++ gst/gstcaps.c | 1 - gst/gststructure.c | 6 ++++++ plugins/elements/gstfakesink.c | 2 +- plugins/elements/gstfakesink.h | 1 + 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 32b3ab0..2a83875 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2006-07-27 Wim Taymans + + * gst/gstcaps.c: (gst_static_caps_get), (gst_caps_get_structure): + Fix useless assert, a uint is always positive. + + * gst/gststructure.c: (gst_structure_nth_field_name), + (gst_structure_foreach), (gst_structure_map_in_place): + Check input arguments for public functions to avoid obvious crashes. + + * plugins/elements/gstfakesink.c: (gst_fake_sink_render): + * plugins/elements/gstfakesink.h: + Do less useless typechecking. + 2006-07-27 Tim-Philipp Müller * plugins/elements/gstfilesrc.c: (gst_file_src_class_init): diff --git a/gst/gstcaps.c b/gst/gstcaps.c index 76bd4e5..78922bd 100644 --- a/gst/gstcaps.c +++ b/gst/gstcaps.c @@ -604,7 +604,6 @@ GstStructure * gst_caps_get_structure (const GstCaps * caps, guint index) { g_return_val_if_fail (GST_IS_CAPS (caps), NULL); - g_return_val_if_fail (index >= 0, NULL); g_return_val_if_fail (index < caps->structs->len, NULL); return g_ptr_array_index (caps->structs, index); diff --git a/gst/gststructure.c b/gst/gststructure.c index 08a34c9..cb22f46 100644 --- a/gst/gststructure.c +++ b/gst/gststructure.c @@ -834,7 +834,11 @@ gst_structure_nth_field_name (const GstStructure * structure, guint index) { GstStructureField *field; + g_return_val_if_fail (structure != NULL, NULL); + g_return_val_if_fail (index < structure->fields->len, NULL); + field = GST_STRUCTURE_FIELD (structure, index); + return g_quark_to_string (field->name); } @@ -859,6 +863,7 @@ gst_structure_foreach (const GstStructure * structure, gboolean ret; g_return_val_if_fail (structure != NULL, FALSE); + g_return_val_if_fail (func != NULL, FALSE); for (i = 0; i < structure->fields->len; i++) { field = GST_STRUCTURE_FIELD (structure, i); @@ -894,6 +899,7 @@ gst_structure_map_in_place (GstStructure * structure, g_return_val_if_fail (structure != NULL, FALSE); g_return_val_if_fail (IS_MUTABLE (structure), FALSE); + g_return_val_if_fail (func != NULL, FALSE); for (i = 0; i < structure->fields->len; i++) { field = GST_STRUCTURE_FIELD (structure, i); diff --git a/plugins/elements/gstfakesink.c b/plugins/elements/gstfakesink.c index 4617ab9..3c8dd0a 100644 --- a/plugins/elements/gstfakesink.c +++ b/plugins/elements/gstfakesink.c @@ -361,7 +361,7 @@ gst_fake_sink_preroll (GstBaseSink * bsink, GstBuffer * buffer) static GstFlowReturn gst_fake_sink_render (GstBaseSink * bsink, GstBuffer * buf) { - GstFakeSink *sink = GST_FAKE_SINK (bsink); + GstFakeSink *sink = GST_FAKE_SINK_CAST (bsink); if (!sink->silent) { gchar ts_str[64], dur_str[64]; diff --git a/plugins/elements/gstfakesink.h b/plugins/elements/gstfakesink.h index b8a5cde..2796492 100644 --- a/plugins/elements/gstfakesink.h +++ b/plugins/elements/gstfakesink.h @@ -40,6 +40,7 @@ G_BEGIN_DECLS (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FAKE_SINK)) #define GST_IS_FAKE_SINK_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FAKE_SINK)) +#define GST_FAKE_SINK_CAST(obj) ((GstFakeSink *)obj) /** * GstFakeSinkStateError: -- 2.7.4