smoothstreamingenc: Fix a memory leak on errors

Message ID 1404658601-3861-1-git-send-email-martin@martin.st
State Committed
Commit a863c97e99bf30a88baa74f83bab9e3ab25984dc
Headers show

Commit Message

Martin Storsjö July 6, 2014, 2:56 p.m.
From: Michael Niedermayer <michaelni@gmx.at>

---
 libavformat/smoothstreamingenc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Diego Biurrun July 6, 2014, 3 p.m. | #1
On Sun, Jul 06, 2014 at 05:56:41PM +0300, Martin Storsjö wrote:
> From: Michael Niedermayer <michaelni@gmx.at>
> 
> ---
>  libavformat/smoothstreamingenc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

LGTM

Diego

Patch

diff --git a/libavformat/smoothstreamingenc.c b/libavformat/smoothstreamingenc.c
index 9fe4fe5..457472d 100644
--- a/libavformat/smoothstreamingenc.c
+++ b/libavformat/smoothstreamingenc.c
@@ -155,9 +155,10 @@  static void get_private_data(OutputStream *os)
         return;
     os->private_str = av_mallocz(2*size + 1);
     if (!os->private_str)
-        return;
+        goto fail;
     for (i = 0; i < size; i++)
         snprintf(&os->private_str[2*i], 3, "%02x", ptr[i]);
+fail:
     if (ptr != codec->extradata)
         av_free(ptr);
 }