diff mbox

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

Message ID 8646ae54-419c-8342-73a6-f6364fd6a416@googlemail.com
State Accepted
Commit c0175fa92b7edd45a06e4ab16c8e83da0c94a9f6
Headers show

Commit Message

Andreas Cadhalpun Nov. 28, 2016, 11:46 p.m. UTC
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@googlemail.com>
---
 libavformat/idroqdec.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Michael Niedermayer Nov. 29, 2016, 1:57 a.m. UTC | #1
On Tue, Nov 29, 2016 at 12:46:11AM +0100, Andreas Cadhalpun wrote:
> The code calls av_new_packet a few lines above and the allocated memory
> has to be freed in case of an error.

should be ok

thx
[...]
Andreas Cadhalpun Nov. 29, 2016, 11:24 p.m. UTC | #2
On 29.11.2016 02:57, Michael Niedermayer wrote:
> On Tue, Nov 29, 2016 at 12:46:11AM +0100, Andreas Cadhalpun wrote:
>> The code calls av_new_packet a few lines above and the allocated memory
>> has to be freed in case of an error.
> 
> should be ok

Pushed.

Best regards,
Andreas
diff mbox

Patch

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;