[vlc-devel] [PATCH] vlc_strftime: avoid infinite loop on windows when format string is invalid

Pierre Lamot pierre at videolabs.io
Thu Jan 25 14:44:12 CET 2018


---
 src/text/strings.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/text/strings.c b/src/text/strings.c
index 4b282bb397..cc26745f07 100644
--- a/src/text/strings.c
+++ b/src/text/strings.c
@@ -506,6 +506,13 @@ char *vlc_strftime( const char *tformat )
             char *ret = realloc (str, len + 1);
             return ret ? ret : str; /* <- this cannot fail */
         }
+#ifdef _WIN32
+        else if ( errno == EINVAL ) /* ie: invalid tformat */
+        {
+            free(str);
+            return NULL;
+        }
+#endif
         free (str);
     }
     vlc_assert_unreachable ();
-- 
2.14.1



More information about the vlc-devel mailing list