[FFmpeg-devel] [PATCH] idroqdec: fix leaking pkt on failure

Andreas Cadhalpun andreas.cadhalpun at googlemail.com
Tue Nov 29 01:46:11 EET 2016


The code calls av_new_packet a few lines above and the allocated memory
has to be freed in case of an error.

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
---
 libavformat/idroqdec.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavformat/idroqdec.c b/libavformat/idroqdec.c
index b664279..c42b3d3 100644
--- a/libavformat/idroqdec.c
+++ b/libavformat/idroqdec.c
@@ -219,8 +219,10 @@ static int roq_read_packet(AVFormatContext *s,
             pkt->pos= avio_tell(pb);
             ret = avio_read(pb, pkt->data + RoQ_CHUNK_PREAMBLE_SIZE,
                 chunk_size);
-            if (ret != chunk_size)
+            if (ret != chunk_size) {
+                av_packet_unref(pkt);
                 ret = AVERROR(EIO);
+            }
 
             packet_read = 1;
             break;
-- 
2.10.2


More information about the ffmpeg-devel mailing list