summaryrefslogtreecommitdiff
path: root/gst/gstdatetime.c
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.net>2012-07-16 00:24:46 +0100
committerTim-Philipp Müller <tim@centricular.net>2012-07-16 00:24:46 +0100
commitd370c1ee2fcaa30a0f310586928fcfcf85fdf2c6 (patch)
tree66b56b7a530a4c890f042506ae1a581a1d199544 /gst/gstdatetime.c
parent49ab4d9a45e7f99d6f3c550e21e4f4ba26f7ef39 (diff)
downloadgstreamer-d370c1ee2fcaa30a0f310586928fcfcf85fdf2c6.tar.gz
datetime: just return NULL on short input strings instead of a warning
We want to be able to use this function on random non-NULL input, this should not result in a runtime-critical.
Diffstat (limited to 'gst/gstdatetime.c')
-rw-r--r--gst/gstdatetime.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/gst/gstdatetime.c b/gst/gstdatetime.c
index b9eaa1d149..6a8f659b3a 100644
--- a/gst/gstdatetime.c
+++ b/gst/gstdatetime.c
@@ -751,12 +751,15 @@ gst_date_time_new_from_iso8601_string (const gchar * string)
guint64 usecs;
gint len, ret;
- len = strlen (string);
+ g_return_val_if_fail (string != NULL, NULL);
+
+ GST_DEBUG ("Parsing '%s' into a datetime", string);
- g_return_val_if_fail (len >= 4, NULL);
- g_return_val_if_fail (g_ascii_isdigit (*string), NULL);
+ len = strlen (string);
- GST_DEBUG ("Parsing %s into a datetime", string);
+ if (len < 4 || !g_ascii_isdigit (string[0]) || !g_ascii_isdigit (string[1])
+ || !g_ascii_isdigit (string[2]) || !g_ascii_isdigit (string[3]))
+ return NULL;
ret = sscanf (string, "%04d-%02d-%02d", &year, &month, &day);