[FFmpeg-devel] [PATCH 09/16] avformat/hlsenc: Check some unchecked allocations
Steven Liu
lq at chinaffmpeg.org
Mon Dec 23 05:59:50 EET 2019
> 在 2019年12月16日,08:04,Andreas Rheinhardt <andreas.rheinhardt at gmail.com> 写道:
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
> ---
> libavformat/hlsenc.c | 13 ++++++++++++-
> 1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 8f142fd475..b3f9582267 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -1614,6 +1614,8 @@ static int hls_start(AVFormatContext *s, VariantStream *vs)
> if (c->use_localtime_mkdir) {
> const char *dir;
> char *fn_copy = av_strdup(oc->url);
> + if (!fn_copy)
> + return AVERROR(ENOMEM);
> dir = av_dirname(fn_copy);
> if (ff_mkdir_p(dir) == -1 && errno != EEXIST) {
> av_log(oc, AV_LOG_ERROR, "Could not create directory %s with use_localtime_mkdir\n", dir);
> @@ -1781,6 +1783,8 @@ static int validate_name(int nb_vs, const char *fn)
> }
>
> fn_dup = av_strdup(fn);
> + if (!fn_dup)
> + return AVERROR(ENOMEM);
> filename = av_basename(fn);
> subdir_name = av_dirname(fn_dup);
>
> @@ -2143,6 +2147,8 @@ static int update_master_pl_info(AVFormatContext *s)
> int ret = 0;
>
> fn1 = av_strdup(s->url);
> + if (!fn1)
> + return AVERROR(ENOMEM);
> dir = av_dirname(fn1);
>
> /**
> @@ -2151,6 +2157,10 @@ static int update_master_pl_info(AVFormatContext *s)
> */
> if (dir && av_stristr(av_basename(dir), "%v")) {
> fn2 = av_strdup(dir);
> + if (!fn2) {
> + ret = AVERROR(ENOMEM);
> + goto fail;
> + }
> dir = av_dirname(fn2);
> }
>
> @@ -2866,7 +2876,8 @@ static int hls_init(AVFormatContext *s)
> if (hls->nb_varstreams > 1) {
> if (av_stristr(vs->fmp4_init_filename, "%v")) {
> av_freep(&vs->fmp4_init_filename);
> - format_name(hls->fmp4_init_filename, &vs->fmp4_init_filename, i, vs->varname);
> + ret = format_name(hls->fmp4_init_filename,
> + &vs->fmp4_init_filename, i, vs->varname);
> } else {
> ret = append_postfix(vs->fmp4_init_filename, fmp4_init_filename_len, i);
> }
> --
> 2.20.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe”.
donnot need check, because the av_dirname has checked it.
Thanks
Steven
More information about the ffmpeg-devel
mailing list