diff mbox

[FFmpeg-devel,v2,2/4] avformat/hlsenc: remove the unnecessary null pointer check

Message ID 20190916112516.14285-2-lance.lmwang@gmail.com
State Accepted
Commit 61aa77272a25d83e5ce5c63d93c64bb9a3e15557
Headers show

Commit Message

Lance Wang Sept. 16, 2019, 11:25 a.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Reviewed-by: Liu Steven <lq@chinaffmpeg.org>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavformat/hlsenc.c | 26 ++------------------------
 1 file changed, 2 insertions(+), 24 deletions(-)

Comments

Liu Steven Sept. 16, 2019, 12:06 p.m. UTC | #1
> 在 2019年9月16日,下午7:25,lance.lmwang@gmail.com 写道:
> 
> From: Limin Wang <lance.lmwang@gmail.com>
> 
> Reviewed-by: Liu Steven <lq@chinaffmpeg.org>
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
> libavformat/hlsenc.c | 26 ++------------------------
> 1 file changed, 2 insertions(+), 24 deletions(-)
> 
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 1f2bdfbe4d..d663785e4a 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -1613,16 +1613,13 @@ 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);
> -                    av_free(fn_copy);
> +                    av_freep(&fn_copy);
>                     return AVERROR(errno);
>                 }
> -                av_free(fn_copy);
> +                av_freep(&fn_copy);
>             }
>         } else {
>             char *filename = NULL;
> @@ -1784,11 +1781,6 @@ static int validate_name(int nb_vs, const char *fn)
>     }
> 
>     fn_dup = av_strdup(fn);
> -    if (!fn_dup) {
> -        ret = AVERROR(ENOMEM);
> -        goto fail;
> -    }
> -
>     filename = av_basename(fn);
>     subdir_name = av_dirname(fn_dup);
> 
> @@ -1846,11 +1838,6 @@ static int format_name(const char *buf, char **s, int index, const char *varname
>     /* if %v is present in the file's directory, create sub-directory */
>     if (av_stristr(dir, "%v") && proto && !strcmp(proto, "file")) {
>         mod_buf_dup = av_strdup(*s);
> -        if (!mod_buf_dup) {
> -            ret = AVERROR(ENOMEM);
> -            goto fail;
> -        }
> -
>         dir = av_dirname(mod_buf_dup);
>         if (ff_mkdir_p(dir) == -1 && errno != EEXIST) {
>             ret = AVERROR(errno);
> @@ -2151,11 +2138,6 @@ static int update_master_pl_info(AVFormatContext *s)
>     int ret = 0;
> 
>     fn1 = av_strdup(s->url);
> -    if (!fn1) {
> -        ret = AVERROR(ENOMEM);
> -        goto fail;
> -    }
> -
>     dir = av_dirname(fn1);
> 
>     /**
> @@ -2164,10 +2146,6 @@ 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);
>     }
> 
> -- 
> 2.21.0
> 
> _______________________________________________
> 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".


No, they need null pointer check, becase there have http protocol, i have paste the output in the last version patch.


Thanks
Steven
Liu Steven Sept. 16, 2019, 1:50 p.m. UTC | #2
> 在 2019年9月16日,20:06,Liu Steven <lq@chinaffmpeg.org> 写道:
> 
> 
> 
>> 在 2019年9月16日,下午7:25,lance.lmwang@gmail.com 写道:
>> 
>> From: Limin Wang <lance.lmwang@gmail.com>
>> 
>> Reviewed-by: Liu Steven <lq@chinaffmpeg.org>
>> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
>> ---
>> libavformat/hlsenc.c | 26 ++------------------------
>> 1 file changed, 2 insertions(+), 24 deletions(-)
>> 
>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>> index 1f2bdfbe4d..d663785e4a 100644
>> --- a/libavformat/hlsenc.c
>> +++ b/libavformat/hlsenc.c
>> @@ -1613,16 +1613,13 @@ 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);
>> -                    av_free(fn_copy);
>> +                    av_freep(&fn_copy);
>>                    return AVERROR(errno);
>>                }
>> -                av_free(fn_copy);
>> +                av_freep(&fn_copy);
>>            }
>>        } else {
>>            char *filename = NULL;
>> @@ -1784,11 +1781,6 @@ static int validate_name(int nb_vs, const char *fn)
>>    }
>> 
>>    fn_dup = av_strdup(fn);
>> -    if (!fn_dup) {
>> -        ret = AVERROR(ENOMEM);
>> -        goto fail;
>> -    }
>> -
>>    filename = av_basename(fn);
>>    subdir_name = av_dirname(fn_dup);
>> 
>> @@ -1846,11 +1838,6 @@ static int format_name(const char *buf, char **s, int index, const char *varname
>>    /* if %v is present in the file's directory, create sub-directory */
>>    if (av_stristr(dir, "%v") && proto && !strcmp(proto, "file")) {
>>        mod_buf_dup = av_strdup(*s);
>> -        if (!mod_buf_dup) {
>> -            ret = AVERROR(ENOMEM);
>> -            goto fail;
>> -        }
>> -
>>        dir = av_dirname(mod_buf_dup);
>>        if (ff_mkdir_p(dir) == -1 && errno != EEXIST) {
>>            ret = AVERROR(errno);
>> @@ -2151,11 +2138,6 @@ static int update_master_pl_info(AVFormatContext *s)
>>    int ret = 0;
>> 
>>    fn1 = av_strdup(s->url);
>> -    if (!fn1) {
>> -        ret = AVERROR(ENOMEM);
>> -        goto fail;
>> -    }
>> -
>>    dir = av_dirname(fn1);
>> 
>>    /**
>> @@ -2164,10 +2146,6 @@ 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);
>>    }
>> 
>> -- 
>> 2.21.0
>> 
>> _______________________________________________
>> 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".
> 
> 
> No, they need null pointer check, becase there have http protocol, i have paste the output in the last version patch.
Ah, i have re check it again, it’s ok.
> 
> 
> Thanks
> Steven
> 
> _______________________________________________
> 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".

Thanks
Steven
diff mbox

Patch

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 1f2bdfbe4d..d663785e4a 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -1613,16 +1613,13 @@  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);
-                    av_free(fn_copy);
+                    av_freep(&fn_copy);
                     return AVERROR(errno);
                 }
-                av_free(fn_copy);
+                av_freep(&fn_copy);
             }
         } else {
             char *filename = NULL;
@@ -1784,11 +1781,6 @@  static int validate_name(int nb_vs, const char *fn)
     }
 
     fn_dup = av_strdup(fn);
-    if (!fn_dup) {
-        ret = AVERROR(ENOMEM);
-        goto fail;
-    }
-
     filename = av_basename(fn);
     subdir_name = av_dirname(fn_dup);
 
@@ -1846,11 +1838,6 @@  static int format_name(const char *buf, char **s, int index, const char *varname
     /* if %v is present in the file's directory, create sub-directory */
     if (av_stristr(dir, "%v") && proto && !strcmp(proto, "file")) {
         mod_buf_dup = av_strdup(*s);
-        if (!mod_buf_dup) {
-            ret = AVERROR(ENOMEM);
-            goto fail;
-        }
-
         dir = av_dirname(mod_buf_dup);
         if (ff_mkdir_p(dir) == -1 && errno != EEXIST) {
             ret = AVERROR(errno);
@@ -2151,11 +2138,6 @@  static int update_master_pl_info(AVFormatContext *s)
     int ret = 0;
 
     fn1 = av_strdup(s->url);
-    if (!fn1) {
-        ret = AVERROR(ENOMEM);
-        goto fail;
-    }
-
     dir = av_dirname(fn1);
 
     /**
@@ -2164,10 +2146,6 @@  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);
     }