From d370c1ee2fcaa30a0f310586928fcfcf85fdf2c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Mon, 16 Jul 2012 00:24:46 +0100 Subject: [PATCH] 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. --- gst/gstdatetime.c | 11 +++++++---- 1 file 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; + g_return_val_if_fail (string != NULL, NULL); + + GST_DEBUG ("Parsing '%s' into a datetime", string); + len = strlen (string); - g_return_val_if_fail (len >= 4, NULL); - g_return_val_if_fail (g_ascii_isdigit (*string), NULL); - - 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);