From 390c6ee42c4971d9809aa1fdee1f4c1d5e98b6ed Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <michael@niedermayer.cc>
Date: Thu, 4 May 2017 13:31:02 +0200
Subject: [PATCH] tools/target_dec_fuzzer: Fix memleak on open failure

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 tools/target_dec_fuzzer.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
index 19423e27f2e..5a0b53e546a 100644
--- a/tools/target_dec_fuzzer.c
+++ b/tools/target_dec_fuzzer.c
@@ -180,8 +180,10 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
     }
 
     int res = avcodec_open2(ctx, c, NULL);
-    if (res < 0)
+    if (res < 0) {
+        av_free(ctx);
         return 0; // Failure of avcodec_open2() does not imply that a issue was found
+    }
 
     FDBCreate(&buffer);
     int got_frame;
-- 
GitLab