fdsrc: use g_ascii_strtoull() to convert size string in uri
authorFrédéric Wang <fred.wang@free.fr>
Thu, 12 Feb 2015 14:50:15 +0000 (14:50 +0000)
committerTim-Philipp Müller <tim@centricular.com>
Thu, 12 Feb 2015 14:50:15 +0000 (14:50 +0000)
sscanf() doesn't handle G_GUINT64_FORMAT well on mingw64 it
appears, leading to compiler warnings.

https://bugzilla.gnome.org/show_bug.cgi?id=744034

plugins/elements/gstfdsrc.c

index 82b8344..8058328 100644 (file)
@@ -645,12 +645,14 @@ gst_fd_src_uri_set_uri (GstURIHandler * handler, const gchar * uri,
   }
 
   if ((q = g_strstr_len (uri, -1, "?"))) {
-    gchar *sp;
+    gchar *sp, *end = NULL;
 
     GST_INFO_OBJECT (src, "found ?");
 
     if ((sp = g_strstr_len (q, -1, "size="))) {
-      if (sscanf (sp, "size=%" G_GUINT64_FORMAT, &size) != 1) {
+      sp += strlen ("size=");
+      size = g_ascii_strtoull (sp, &end, 10);
+      if ((size == 0 && errno == EINVAL) || size == G_MAXUINT64 || end == sp) {
         GST_INFO_OBJECT (src, "parsing size failed");
         size = -1;
       } else {