avformat/hlsenc: Fix return value from localtime_r failure
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Mon, 16 Dec 2019 00:04:12 +0000 (01:04 +0100)
committerSteven Liu <lq@chinaffmpeg.org>
Mon, 23 Dec 2019 06:05:47 +0000 (14:05 +0800)
"If an error is detected, localtime_r() shall return a null pointer
and set errno to indicate the error." Yet in case this happened in
hls_init(), AVERROR(ENOMEM) has been returned.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Reviewed-by: Steven Liu <lq@onvideo.cn>
libavformat/hlsenc.c

index f804250..f3e89a0 100644 (file)
@@ -2737,7 +2737,7 @@ static int hls_init(AVFormatContext *s)
             char b[15];
             struct tm *p, tmbuf;
             if (!(p = localtime_r(&t, &tmbuf)))
-                return AVERROR(ENOMEM);
+                return AVERROR(errno);
             if (!strftime(b, sizeof(b), "%Y%m%d%H%M%S", p))
                 return AVERROR(ENOMEM);
             hls->start_sequence = strtoll(b, NULL, 10);