From 7f8e9d9b7716b1193e40dd8029268ed994ed18a5 Mon Sep 17 00:00:00 2001
From: John Rummell <jrummell@chromium.org>
Date: Mon, 30 Mar 2020 14:08:01 -0700
Subject: [PATCH] libavformat/mov.c: Free aes_decrypt to avoid leaking memory

Found by Chromium fuzzers (crbug.com/1057205).

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit ad91cf1f2f5793db5c6dd7ab9947fcc6d7832607)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavformat/mov.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 8ca2e90bdb..512f6a076a 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1004,6 +1004,7 @@ static int mov_read_adrm(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     sha = av_sha_alloc();
     if (!sha)
         return AVERROR(ENOMEM);
+    av_free(c->aes_decrypt);
     c->aes_decrypt = av_aes_alloc();
     if (!c->aes_decrypt) {
         ret = AVERROR(ENOMEM);