gst/gstvalue.c: Handle NULL input and output pointers silently as a failed conversion...
authorJan Schmidt <thaytan@mad.scientist.com>
Fri, 26 May 2006 09:19:24 +0000 (09:19 +0000)
committerJan Schmidt <thaytan@mad.scientist.com>
Fri, 26 May 2006 09:19:24 +0000 (09:19 +0000)
Original commit message from CVS:
* gst/gstvalue.c: (gst_value_deserialize_fraction):
Handle NULL input and output pointers silently as a failed conversion,
rather than g_warnings.

ChangeLog
gst/gstvalue.c

index b145007..9b6f1fe 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-05-26  Jan Schmidt  <thaytan@mad.scientist.com>
+
+       * gst/gstvalue.c: (gst_value_deserialize_fraction):
+       Handle NULL input and output pointers silently as a failed conversion,
+       rather than g_warnings.
+
 2006-05-25  Wim Taymans  <wim@fluendo.com>
 
        * libs/gst/net/gstnetclientclock.c: (gst_net_client_clock_start):
index 5016c55..0a06290 100644 (file)
@@ -3389,11 +3389,17 @@ gst_value_deserialize_fraction (GValue * dest, const gchar * s)
 {
   gint num, den;
 
-  if (s && sscanf (s, "%d/%d", &num, &den) == 2) {
+  if (G_UNLIKELY (s == NULL))
+    return FALSE;
+
+  if (G_UNLIKELY (dest == NULL || !GST_VALUE_HOLDS_FRACTION (dest)))
+    return FALSE;
+
+  if (sscanf (s, "%d/%d", &num, &den) == 2) {
     gst_value_set_fraction (dest, num, den);
     return TRUE;
   }
-  if (s && sscanf (s, "%d", &num) == 1) {
+  if (sscanf (s, "%d", &num) == 1) {
     gst_value_set_fraction (dest, num, 1);
     return TRUE;
   }