diff mbox

[FFmpeg-devel] matroskaenc: fix leak on error

Message ID 20190404165626.22548-1-tmatth@videolan.org
State Accepted
Commit 1ec777dcdd03b43d3d694c3b4532dccea0b419f0
Headers show

Commit Message

Tristan Matthews April 4, 2019, 4:56 p.m. UTC
---
 libavformat/matroskaenc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Tristan Matthews April 9, 2019, 1:28 p.m. UTC | #1
On Thu, Apr 4, 2019 at 12:56 PM Tristan Matthews <tmatth@videolan.org> wrote:
>
> ---
>  libavformat/matroskaenc.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
> index b9f99c4463..1a06103c5d 100644
> --- a/libavformat/matroskaenc.c
> +++ b/libavformat/matroskaenc.c
> @@ -694,8 +694,10 @@ static int put_flac_codecpriv(AVFormatContext *s,
>          av_dict_set(&dict, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK", buf, 0);
>
>          len = ff_vorbiscomment_length(dict, vendor, NULL, 0);
> -        if (len >= ((1<<24) - 4))
> +        if (len >= ((1<<24) - 4)) {
> +            av_dict_free(&dict);
>              return AVERROR(EINVAL);
> +        }
>
>          data = av_malloc(len + 4);
>          if (!data) {
> --
> 2.17.1
>

Ping (this shouldn't conflict with any of the recent matroskaenc patches).

Best,
Tristan
James Almer April 9, 2019, 1:50 p.m. UTC | #2
On 4/9/2019 10:28 AM, Tristan Matthews wrote:
> On Thu, Apr 4, 2019 at 12:56 PM Tristan Matthews <tmatth@videolan.org> wrote:
>>
>> ---
>>  libavformat/matroskaenc.c | 4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
>> index b9f99c4463..1a06103c5d 100644
>> --- a/libavformat/matroskaenc.c
>> +++ b/libavformat/matroskaenc.c
>> @@ -694,8 +694,10 @@ static int put_flac_codecpriv(AVFormatContext *s,
>>          av_dict_set(&dict, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK", buf, 0);
>>
>>          len = ff_vorbiscomment_length(dict, vendor, NULL, 0);
>> -        if (len >= ((1<<24) - 4))
>> +        if (len >= ((1<<24) - 4)) {
>> +            av_dict_free(&dict);
>>              return AVERROR(EINVAL);
>> +        }
>>
>>          data = av_malloc(len + 4);
>>          if (!data) {
>> --
>> 2.17.1
>>
> 
> Ping (this shouldn't conflict with any of the recent matroskaenc patches).
> 
> Best,
> Tristan

Pushed, thanks.
diff mbox

Patch

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index b9f99c4463..1a06103c5d 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -694,8 +694,10 @@  static int put_flac_codecpriv(AVFormatContext *s,
         av_dict_set(&dict, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK", buf, 0);
 
         len = ff_vorbiscomment_length(dict, vendor, NULL, 0);
-        if (len >= ((1<<24) - 4))
+        if (len >= ((1<<24) - 4)) {
+            av_dict_free(&dict);
             return AVERROR(EINVAL);
+        }
 
         data = av_malloc(len + 4);
         if (!data) {