diff mbox

[FFmpeg-devel,v3] libavformat/rtsp: return error if rtsp_hd_out is null instead of crash

Message ID 20190918204214.13234-1-phunkyfish@gmail.com
State Superseded
Headers show

Commit Message

Ross Nicholson Sept. 18, 2019, 8:42 p.m. UTC
---
 libavformat/rtsp.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Ross Nicholson Sept. 18, 2019, 8:51 p.m. UTC | #1
Technically this function should also return an error is rt is NULL. Which
error code would apply for this?

On Wed, 18 Sep 2019 at 21:42, phunkyfish <phunkyfish@gmail.com> wrote:

> ---
>  libavformat/rtsp.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> index c153cac88b..5e8adfaf3c 100644
> --- a/libavformat/rtsp.c
> +++ b/libavformat/rtsp.c
> @@ -1318,6 +1318,9 @@ static int
> rtsp_send_cmd_with_content_async(AVFormatContext *s,
>      char buf[4096], *out_buf;
>      char base64buf[AV_BASE64_SIZE(sizeof(buf))];
>
> +    if (rt && !rt->rtsp_hd_out)
> +        return ENOTCONN;
> +
>      /* Add in RTSP headers */
>      out_buf = buf;
>      rt->seq++;
> --
> 2.20.1 (Apple Git-117)
>
>
Ross Nicholson Sept. 18, 2019, 8:56 p.m. UTC | #2
Checking other functions I don't see this checked for so I guess latest
patch is fine.

On Wed, 18 Sep 2019 at 21:51, Ross Nicholson <phunkyfish@gmail.com> wrote:

> Technically this function should also return an error is rt is NULL. Which
> error code would apply for this?
>
> On Wed, 18 Sep 2019 at 21:42, phunkyfish <phunkyfish@gmail.com> wrote:
>
>> ---
>>  libavformat/rtsp.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
>> index c153cac88b..5e8adfaf3c 100644
>> --- a/libavformat/rtsp.c
>> +++ b/libavformat/rtsp.c
>> @@ -1318,6 +1318,9 @@ static int
>> rtsp_send_cmd_with_content_async(AVFormatContext *s,
>>      char buf[4096], *out_buf;
>>      char base64buf[AV_BASE64_SIZE(sizeof(buf))];
>>
>> +    if (rt && !rt->rtsp_hd_out)
>> +        return ENOTCONN;
>> +
>>      /* Add in RTSP headers */
>>      out_buf = buf;
>>      rt->seq++;
>> --
>> 2.20.1 (Apple Git-117)
>>
>>
Michael Niedermayer Sept. 20, 2019, 12:02 p.m. UTC | #3
On Wed, Sep 18, 2019 at 09:42:14PM +0100, phunkyfish wrote:
> ---
>  libavformat/rtsp.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> index c153cac88b..5e8adfaf3c 100644
> --- a/libavformat/rtsp.c
> +++ b/libavformat/rtsp.c
> @@ -1318,6 +1318,9 @@ static int rtsp_send_cmd_with_content_async(AVFormatContext *s,
>      char buf[4096], *out_buf;
>      char base64buf[AV_BASE64_SIZE(sizeof(buf))];
>  
> +    if (rt && !rt->rtsp_hd_out)
> +        return ENOTCONN;
> +
>      /* Add in RTSP headers */
>      out_buf = buf;
>      rt->seq++;


if (rt && ...
implies that rt can be NULL

rt->seq++; implies rt is not NULL


[...]
Ross Nicholson Sept. 20, 2019, 1:17 p.m. UTC | #4
Makes sense. Latest version of patch v4 should reflect this.

> On 18 Sep 2019, at 21:42, phunkyfish <phunkyfish@gmail.com> wrote:
> 
> ---
> libavformat/rtsp.c | 3 +++
> 1 file changed, 3 insertions(+)
> 
> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> index c153cac88b..5e8adfaf3c 100644
> --- a/libavformat/rtsp.c
> +++ b/libavformat/rtsp.c
> @@ -1318,6 +1318,9 @@ static int rtsp_send_cmd_with_content_async(AVFormatContext *s,
>     char buf[4096], *out_buf;
>     char base64buf[AV_BASE64_SIZE(sizeof(buf))];
> 
> +    if (rt && !rt->rtsp_hd_out)
> +        return ENOTCONN;
> +
>     /* Add in RTSP headers */
>     out_buf = buf;
>     rt->seq++;
> -- 
> 2.20.1 (Apple Git-117)
>
diff mbox

Patch

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index c153cac88b..5e8adfaf3c 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -1318,6 +1318,9 @@  static int rtsp_send_cmd_with_content_async(AVFormatContext *s,
     char buf[4096], *out_buf;
     char base64buf[AV_BASE64_SIZE(sizeof(buf))];
 
+    if (rt && !rt->rtsp_hd_out)
+        return ENOTCONN;
+
     /* Add in RTSP headers */
     out_buf = buf;
     rt->seq++;