diff mbox

[FFmpeg-devel,10/16] avformat/hlsenc: Fix return value from localtime_r failure

Message ID 20191216000418.24707-11-andreas.rheinhardt@gmail.com
State Accepted
Commit 53c1458bf2e91b2279985e5fc2ffaa5e2013564a
Headers show

Commit Message

Andreas Rheinhardt Dec. 16, 2019, 12:04 a.m. UTC
"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>
---
 libavformat/hlsenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Liu Steven Dec. 16, 2019, 2:55 a.m. UTC | #1
> 在 2019年12月16日,08:04,Andreas Rheinhardt <andreas.rheinhardt@gmail.com> 写道:
> 
> "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>
> ---
> libavformat/hlsenc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index b3f9582267..669641885e 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -2747,7 +2747,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);
> -- 
> 2.20.1
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

LGTM

Thanks
Steven
diff mbox

Patch

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index b3f9582267..669641885e 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -2747,7 +2747,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);