[vlc-devel] [PATCH] vlc_strftime: avoid infinite loop on windows when format string is invalid
Romain Vimont
rom at rom1v.com
Thu Jan 25 15:16:05 CET 2018
On Thu, Jan 25, 2018 at 02:44:12PM +0100, Pierre Lamot wrote:
> ---
> 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 */
Since strftime() returning 0 does not necessarily indicate an error,
errno should be set to 0 before the call (otherwise, it may contain
garbage value).
But I think this corner case is not handled correctly anyway in this
function. "man strftime" says:
> For example, in many locales %p yields an empty string.
> + {
> + free(str);
> + return NULL;
> + }
> +#endif
> free (str);
> }
> vlc_assert_unreachable ();
> --
> 2.14.1
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
More information about the vlc-devel
mailing list