[FFmpeg-devel] [PATCH] avformat/avio: check input URLContext value NULL
Jun Zhao
mypopydev at gmail.com
Mon Nov 20 09:23:03 EET 2017
On 2017/11/20 14:45, Steven Liu wrote:
> fix ticket id: #6846
>
> Signed-off-by: Steven Liu <lq at chinaffmpeg.org>
> ---
> libavformat/avio.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/libavformat/avio.c b/libavformat/avio.c
> index 4dc468350c..e719326660 100644
> --- a/libavformat/avio.c
> +++ b/libavformat/avio.c
> @@ -625,6 +625,8 @@ int64_t ffurl_size(URLContext *h)
>
> int ffurl_get_file_handle(URLContext *h)
> {
> + if (!h)
> + return AVERROR(EINVAL);
> if (!h->prot->url_get_file_handle)
I think (!h && !h->prot && !h->prot->url_get_file_handle) more better
than this
> return -1;
> return h->prot->url_get_file_handle(h);
> @@ -632,6 +634,8 @@ int ffurl_get_file_handle(URLContext *h)
>
> int ffurl_get_multi_file_handle(URLContext *h, int **handles, int *numhandles)
> {
> + if (!h)
> + return AVERROR(EINVAL);
> if (!h->prot->url_get_multi_file_handle) {
> if (!h->prot->url_get_file_handle)
> return AVERROR(ENOSYS);
> @@ -647,6 +651,8 @@ int ffurl_get_multi_file_handle(URLContext *h, int **handles, int *numhandles)
>
> int ffurl_get_short_seek(URLContext *h)
> {
> + if (!h)
> + return AVERROR(EINVAL);
> if (!h->prot->url_get_short_seek)
> return AVERROR(ENOSYS);
> return h->prot->url_get_short_seek(h);
> @@ -654,6 +660,8 @@ int ffurl_get_short_seek(URLContext *h)
>
> int ffurl_shutdown(URLContext *h, int flags)
> {
> + if (!h)
> + return AVERROR(EINVAL);
> if (!h->prot->url_shutdown)
> return AVERROR(EINVAL);
> return h->prot->url_shutdown(h, flags);
More information about the ffmpeg-devel
mailing list