rtsp: Check a memory allocation

Message ID 1413397738-21705-1-git-send-email-martin@martin.st
State Committed
Commit b31bb39bdd7b5a53e0d282acc0f0f62b32b17acc
Headers show

Commit Message

Martin Storsjö Oct. 15, 2014, 6:28 p.m.
From: Michael Lynch <mtlynch@google.com>

CC: libav-stable@libav.org
---
 libavformat/rtsp.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Luca Barbato Oct. 15, 2014, 6:31 p.m. | #1
On 15/10/14 20:28, Martin Storsjö wrote:
> From: Michael Lynch <mtlynch@google.com>
>
> CC: libav-stable@libav.org
> ---
>   libavformat/rtsp.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> index d574797..52f52a1 100644
> --- a/libavformat/rtsp.c
> +++ b/libavformat/rtsp.c
> @@ -1146,6 +1146,8 @@ start:
>       if (content_length > 0) {
>           /* leave some room for a trailing '\0' (useful for simple parsing) */
>           content = av_malloc(content_length + 1);
> +        if (!content)
> +            return AVERROR(ENOMEM);
>           ffurl_read_complete(rt->rtsp_hd, content, content_length);
>           content[content_length] = '\0';
>       }
>

Looks fine.

Patch

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index d574797..52f52a1 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -1146,6 +1146,8 @@  start:
     if (content_length > 0) {
         /* leave some room for a trailing '\0' (useful for simple parsing) */
         content = av_malloc(content_length + 1);
+        if (!content)
+            return AVERROR(ENOMEM);
         ffurl_read_complete(rt->rtsp_hd, content, content_length);
         content[content_length] = '\0';
     }