From 1e79d5c6e73ad131f9395f337b58a2b59ee04c1b Mon Sep 17 00:00:00 2001
From: James Almer <jamrial@gmail.com>
Date: Tue, 16 Jun 2015 17:27:20 +0100
Subject: [PATCH] libwebpenc: use WebPMemoryWriterClear()

WebPMemoryWriterClear() must be used instead of free() when
libwebp ABI version is > 0x0203.

Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
---
 libavcodec/libwebpenc.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/libwebpenc.c b/libavcodec/libwebpenc.c
index b981f48245f..ef311b75921 100644
--- a/libavcodec/libwebpenc.c
+++ b/libavcodec/libwebpenc.c
@@ -231,7 +231,11 @@ static int libwebp_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     *got_packet = 1;
 
 end:
+#if (WEBP_ENCODER_ABI_VERSION > 0x0203)
+    WebPMemoryWriterClear(&mw);
+#else
     free(mw.mem); /* must use free() according to libwebp documentation */
+#endif
     WebPPictureFree(pic);
     av_freep(&pic);
     av_frame_free(&alt_frame);
-- 
GitLab