diff mbox

[FFmpeg-devel,07/11] avfilter/vf_signature: fix memory leaks in error cases

Message ID 20170611140551.11844-7-timo@rothenpieler.org
State Accepted
Commit feb13aed794a7f1a1f8395159e9b077351348a34
Headers show

Commit Message

Timo Rothenpieler June 11, 2017, 2:05 p.m. UTC
Fixes CIDs 1403234 and 1403235
---
 libavfilter/vf_signature.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Michael Niedermayer June 12, 2017, 10:24 p.m. UTC | #1
On Sun, Jun 11, 2017 at 04:05:49PM +0200, Timo Rothenpieler wrote:
> Fixes CIDs 1403234 and 1403235
> ---
>  libavfilter/vf_signature.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

LGTM

thx

PS: i wont review the remaining signature fix, as its not obvious
to me if the condition is possible, maybe mail the author if he doesnt
spot the patch

[...]
Timo Rothenpieler June 13, 2017, 5:54 p.m. UTC | #2
Am 13.06.2017 um 00:24 schrieb Michael Niedermayer:
> On Sun, Jun 11, 2017 at 04:05:49PM +0200, Timo Rothenpieler wrote:
>> Fixes CIDs 1403234 and 1403235
>> ---
>>   libavfilter/vf_signature.c | 5 ++++-
>>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> LGTM
> 
> thx

applied
diff mbox

Patch

diff --git a/libavfilter/vf_signature.c b/libavfilter/vf_signature.c
index 06b1b910d4..f0078ba1a6 100644
--- a/libavfilter/vf_signature.c
+++ b/libavfilter/vf_signature.c
@@ -260,8 +260,10 @@  static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
         if (!elemsignature)
             return AVERROR(ENOMEM);
         sortsignature = av_malloc_array(elemcat->elem_count, sizeof(int64_t));
-        if (!sortsignature)
+        if (!sortsignature) {
+            av_freep(&elemsignature);
             return AVERROR(ENOMEM);
+        }
 
         for (j = 0; j < elemcat->elem_count; j++) {
             blocksum = 0;
@@ -508,6 +510,7 @@  static int binary_export(AVFilterContext *ctx, StreamContext *sc, const char* fi
         char buf[128];
         av_strerror(err, buf, sizeof(buf));
         av_log(ctx, AV_LOG_ERROR, "cannot open file %s: %s\n", filename, buf);
+        av_freep(&buffer);
         return err;
     }
     init_put_bits(&buf, buffer, len);