diff mbox series

[FFmpeg-devel,10/11] avformat/wtvdec: Fix memleak when reading header fails

Message ID 20200107135549.22581-10-andreas.rheinhardt@gmail.com
State Accepted
Headers show
Series [FFmpeg-devel,01/11] avformat/avformat: Update AVInputFormat.read_packet documentation
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork success Applied patch
andriy/ffmpeg-patchwork success Configure finished
andriy/ffmpeg-patchwork success Make finished
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Andreas Rheinhardt Jan. 7, 2020, 1:55 p.m. UTC
Fixes #8314.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/wtvdec.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Peter Ross Jan. 8, 2020, 1:17 a.m. UTC | #1
On Tue, Jan 07, 2020 at 02:55:48PM +0100, Andreas Rheinhardt wrote:
> Fixes #8314.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavformat/wtvdec.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c
> index 706e8ca38d..92629bb31b 100644
> --- a/libavformat/wtvdec.c
> +++ b/libavformat/wtvdec.c
> @@ -993,8 +993,10 @@ static int read_header(AVFormatContext *s)
>      }
>  
>      ret = parse_chunks(s, SEEK_TO_DATA, 0, 0);
> -    if (ret < 0)
> +    if (ret < 0) {
> +        wtvfile_close(wtv->pb);
>          return ret;
> +    }
>      avio_seek(wtv->pb, -32, SEEK_CUR);
>  
>      timeline_pos = avio_tell(s->pb); // save before opening another file
> -- 
> 2.20.1

looks good. please apply.

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
James Almer Jan. 8, 2020, 1:38 a.m. UTC | #2
On 1/7/2020 10:17 PM, Peter Ross wrote:
> On Tue, Jan 07, 2020 at 02:55:48PM +0100, Andreas Rheinhardt wrote:
>> Fixes #8314.
>>
>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
>> ---
>>  libavformat/wtvdec.c | 4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c
>> index 706e8ca38d..92629bb31b 100644
>> --- a/libavformat/wtvdec.c
>> +++ b/libavformat/wtvdec.c
>> @@ -993,8 +993,10 @@ static int read_header(AVFormatContext *s)
>>      }
>>  
>>      ret = parse_chunks(s, SEEK_TO_DATA, 0, 0);
>> -    if (ret < 0)
>> +    if (ret < 0) {
>> +        wtvfile_close(wtv->pb);
>>          return ret;
>> +    }
>>      avio_seek(wtv->pb, -32, SEEK_CUR);
>>  
>>      timeline_pos = avio_tell(s->pb); // save before opening another file
>> -- 
>> 2.20.1
> 
> looks good. please apply.

Applied.
diff mbox series

Patch

diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c
index 706e8ca38d..92629bb31b 100644
--- a/libavformat/wtvdec.c
+++ b/libavformat/wtvdec.c
@@ -993,8 +993,10 @@  static int read_header(AVFormatContext *s)
     }
 
     ret = parse_chunks(s, SEEK_TO_DATA, 0, 0);
-    if (ret < 0)
+    if (ret < 0) {
+        wtvfile_close(wtv->pb);
         return ret;
+    }
     avio_seek(wtv->pb, -32, SEEK_CUR);
 
     timeline_pos = avio_tell(s->pb); // save before opening another file