From: Wim Taymans Date: Tue, 14 Mar 2006 19:16:45 +0000 (+0000) Subject: gst/gstformat.c: Don't segfault on invalid formats. X-Git-Tag: RELEASE-0_10_5~93 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=34e8d485cc75651f0f8e1362f62f2a7b28e01c4c;p=platform%2Fupstream%2Fgstreamer.git gst/gstformat.c: Don't segfault on invalid formats. Original commit message from CVS: * gst/gstformat.c: (gst_format_get_name), (gst_format_to_quark): Don't segfault on invalid formats. --- diff --git a/ChangeLog b/ChangeLog index 7afca8f..e17dd10 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-03-14 Wim Taymans + + * gst/gstformat.c: (gst_format_get_name), (gst_format_to_quark): + Don't segfault on invalid formats. + 2006-03-14 Tim-Philipp Müller * libs/gst/base/gstbasesink.c: (gst_base_sink_get_sync_times): diff --git a/gst/gstformat.c b/gst/gstformat.c index 4153678..3d0acad 100644 --- a/gst/gstformat.c +++ b/gst/gstformat.c @@ -81,16 +81,21 @@ _gst_format_initialize (void) * * Get a printable name for the given format. Do not modify or free. * - * Returns: a reference to the static name of the format. + * Returns: a reference to the static name of the format or NULL if + * the format is unknown. */ const gchar * gst_format_get_name (GstFormat format) { const GstFormatDefinition *def; + const gchar *result; - def = gst_format_get_details (format); + if ((def = gst_format_get_details (format)) != NULL) + result = def->nick; + else + result = NULL; - return def->nick; + return result; } /** @@ -99,16 +104,21 @@ gst_format_get_name (GstFormat format) * * Get the unique quark for the given format. * - * Returns: the quark associated with the format + * Returns: the quark associated with the format or 0 if the format + * is unknown. */ GQuark gst_format_to_quark (GstFormat format) { const GstFormatDefinition *def; + GQuark result; - def = gst_format_get_details (format); + if ((def = gst_format_get_details (format)) != NULL) + result = def->quark; + else + result = 0; - return def->quark; + return result; } /**