diff mbox

[FFmpeg-devel] avformat/avio: check input URLContext value NULL

Message ID 20171120075859.30817-1-lq@chinaffmpeg.org
State Accepted
Commit be4dfbf7b71e44a53ca8da882a081e35ea134c83
Headers show

Commit Message

Liu Steven Nov. 20, 2017, 7:58 a.m. UTC
fix ticket id: #6846

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 libavformat/avio.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Steven Liu Dec. 27, 2017, 6:18 a.m. UTC | #1
2017-11-20 15:58 GMT+08:00 Steven Liu <lq@chinaffmpeg.org>:
> fix ticket id: #6846
>
> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> ---
>  libavformat/avio.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/libavformat/avio.c b/libavformat/avio.c
> index 4dc468350c..63e82872f7 100644
> --- a/libavformat/avio.c
> +++ b/libavformat/avio.c
> @@ -625,13 +625,15 @@ int64_t ffurl_size(URLContext *h)
>
>  int ffurl_get_file_handle(URLContext *h)
>  {
> -    if (!h->prot->url_get_file_handle)
> +    if (!h || !h->prot || !h->prot->url_get_file_handle)
>          return -1;
>      return h->prot->url_get_file_handle(h);
>  }
>
>  int ffurl_get_multi_file_handle(URLContext *h, int **handles, int *numhandles)
>  {
> +    if (!h || !h->prot)
> +        return AVERROR(ENOSYS);
>      if (!h->prot->url_get_multi_file_handle) {
>          if (!h->prot->url_get_file_handle)
>              return AVERROR(ENOSYS);
> @@ -647,15 +649,15 @@ int ffurl_get_multi_file_handle(URLContext *h, int **handles, int *numhandles)
>
>  int ffurl_get_short_seek(URLContext *h)
>  {
> -    if (!h->prot->url_get_short_seek)
> +    if (!h || !h->prot || !h->prot->url_get_short_seek)
>          return AVERROR(ENOSYS);
>      return h->prot->url_get_short_seek(h);
>  }
>
>  int ffurl_shutdown(URLContext *h, int flags)
>  {
> -    if (!h->prot->url_shutdown)
> -        return AVERROR(EINVAL);
> +    if (!h || !h->prot || !h->prot->url_shutdown)
> +        return AVERROR(ENOSYS);
>      return h->prot->url_shutdown(h, flags);
>  }
>
> --
> 2.13.6 (Apple Git-96)
>
>
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
ping
Jeyapal, Karthick Dec. 27, 2017, 6:40 a.m. UTC | #2
On 12/27/17, 11:55 AM, "Steven Liu" <lingjiujianke@gmail.com> wrote:

>2017-11-20 15:58 GMT+08:00 Steven Liu <lq@chinaffmpeg.org>:

>> fix ticket id: #6846

>>

>> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>

>> ---

>>  libavformat/avio.c | 10 ++++++----

>>  1 file changed, 6 insertions(+), 4 deletions(-)

>>

>>[…]

>>  int ffurl_shutdown(URLContext *h, int flags)

>>  {

>> -    if (!h->prot->url_shutdown)

>> -        return AVERROR(EINVAL);

>> +    if (!h || !h->prot || !h->prot->url_shutdown)

>> +        return AVERROR(ENOSYS);

>>      return h->prot->url_shutdown(h, flags);

>>  }

>>

>> --

>> 2.13.6 (Apple Git-96)

>>

>>

>>

>> _______________________________________________

>> ffmpeg-devel mailing list

>> ffmpeg-devel@ffmpeg.org

>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

>ping


LGTM. 
In fact, I would like this change to be merged to handle some error cases in hlsenc as well.

Thanks,
Karthick
Michael Niedermayer Dec. 27, 2017, 11:04 p.m. UTC | #3
On Mon, Nov 20, 2017 at 03:58:59PM +0800, Steven Liu wrote:
> fix ticket id: #6846
> 
> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> ---
>  libavformat/avio.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)

LGTM

thx

[...]
Liu Steven Dec. 28, 2017, 5:52 a.m. UTC | #4
> On 28 Dec 2017, at 07:04, Michael Niedermayer <michael@niedermayer.cc> wrote:
> 
> On Mon, Nov 20, 2017 at 03:58:59PM +0800, Steven Liu wrote:
>> fix ticket id: #6846
>> 
>> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
>> ---
>> libavformat/avio.c | 10 ++++++----
>> 1 file changed, 6 insertions(+), 4 deletions(-)
> 
> LGTM
> 
> thx


Pushed

Thanks
Steven
> 
> [...]
> -- 
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> Rewriting code that is poorly written but fully understood is good.
> Rewriting code that one doesnt understand is a sign that one is less smart
> then the original author, trying to rewrite it will not make it better.
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
diff mbox

Patch

diff --git a/libavformat/avio.c b/libavformat/avio.c
index 4dc468350c..63e82872f7 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -625,13 +625,15 @@  int64_t ffurl_size(URLContext *h)
 
 int ffurl_get_file_handle(URLContext *h)
 {
-    if (!h->prot->url_get_file_handle)
+    if (!h || !h->prot || !h->prot->url_get_file_handle)
         return -1;
     return h->prot->url_get_file_handle(h);
 }
 
 int ffurl_get_multi_file_handle(URLContext *h, int **handles, int *numhandles)
 {
+    if (!h || !h->prot)
+        return AVERROR(ENOSYS);
     if (!h->prot->url_get_multi_file_handle) {
         if (!h->prot->url_get_file_handle)
             return AVERROR(ENOSYS);
@@ -647,15 +649,15 @@  int ffurl_get_multi_file_handle(URLContext *h, int **handles, int *numhandles)
 
 int ffurl_get_short_seek(URLContext *h)
 {
-    if (!h->prot->url_get_short_seek)
+    if (!h || !h->prot || !h->prot->url_get_short_seek)
         return AVERROR(ENOSYS);
     return h->prot->url_get_short_seek(h);
 }
 
 int ffurl_shutdown(URLContext *h, int flags)
 {
-    if (!h->prot->url_shutdown)
-        return AVERROR(EINVAL);
+    if (!h || !h->prot || !h->prot->url_shutdown)
+        return AVERROR(ENOSYS);
     return h->prot->url_shutdown(h, flags);
 }