diff mbox series

[FFmpeg-devel,1/3] avcodec/libopusenc: Don't free user-provided AVPacket

Message ID 20200523104413.10023-1-andreas.rheinhardt@gmail.com
State Accepted
Commit b803993b6d99423c8c1e01e7e206e3916a98d5d5
Headers show
Series [FFmpeg-devel,1/3] avcodec/libopusenc: Don't free user-provided AVPacket | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Andreas Rheinhardt May 23, 2020, 10:44 a.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/libopusenc.c | 2 --
 1 file changed, 2 deletions(-)

Comments

James Almer May 23, 2020, 1:47 p.m. UTC | #1
On 5/23/2020 7:44 AM, Andreas Rheinhardt wrote:
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavcodec/libopusenc.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/libavcodec/libopusenc.c b/libavcodec/libopusenc.c
> index 7c025a66d7..13017ac323 100644
> --- a/libavcodec/libopusenc.c
> +++ b/libavcodec/libopusenc.c
> @@ -503,7 +503,6 @@ static int libopus_encode(AVCodecContext *avctx, AVPacket *avpkt,
>      // Check if subtraction resulted in an overflow
>      if ((discard_padding < opus->opts.packet_size) != (avpkt->duration > 0)) {
>          av_packet_unref(avpkt);
> -        av_free(avpkt);
>          return AVERROR(EINVAL);
>      }
>      if (discard_padding > 0) {
> @@ -512,7 +511,6 @@ static int libopus_encode(AVCodecContext *avctx, AVPacket *avpkt,
>                                                       10);
>          if(!side_data) {
>              av_packet_unref(avpkt);
> -            av_free(avpkt);
>              return AVERROR(ENOMEM);
>          }
>          AV_WL32(side_data + 4, discard_padding);

LGTM of course. And please backport it.
Andreas Rheinhardt May 23, 2020, 8:01 p.m. UTC | #2
James Almer:
> On 5/23/2020 7:44 AM, Andreas Rheinhardt wrote:
>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
>> ---
>>  libavcodec/libopusenc.c | 2 --
>>  1 file changed, 2 deletions(-)
>>
>> diff --git a/libavcodec/libopusenc.c b/libavcodec/libopusenc.c
>> index 7c025a66d7..13017ac323 100644
>> --- a/libavcodec/libopusenc.c
>> +++ b/libavcodec/libopusenc.c
>> @@ -503,7 +503,6 @@ static int libopus_encode(AVCodecContext *avctx, AVPacket *avpkt,
>>      // Check if subtraction resulted in an overflow
>>      if ((discard_padding < opus->opts.packet_size) != (avpkt->duration > 0)) {
>>          av_packet_unref(avpkt);
>> -        av_free(avpkt);
>>          return AVERROR(EINVAL);
>>      }
>>      if (discard_padding > 0) {
>> @@ -512,7 +511,6 @@ static int libopus_encode(AVCodecContext *avctx, AVPacket *avpkt,
>>                                                       10);
>>          if(!side_data) {
>>              av_packet_unref(avpkt);
>> -            av_free(avpkt);
>>              return AVERROR(ENOMEM);
>>          }
>>          AV_WL32(side_data + 4, discard_padding);
> 
> LGTM of course. And please backport it.

Applied and backported up to 2.8.

- Andreas
diff mbox series

Patch

diff --git a/libavcodec/libopusenc.c b/libavcodec/libopusenc.c
index 7c025a66d7..13017ac323 100644
--- a/libavcodec/libopusenc.c
+++ b/libavcodec/libopusenc.c
@@ -503,7 +503,6 @@  static int libopus_encode(AVCodecContext *avctx, AVPacket *avpkt,
     // Check if subtraction resulted in an overflow
     if ((discard_padding < opus->opts.packet_size) != (avpkt->duration > 0)) {
         av_packet_unref(avpkt);
-        av_free(avpkt);
         return AVERROR(EINVAL);
     }
     if (discard_padding > 0) {
@@ -512,7 +511,6 @@  static int libopus_encode(AVCodecContext *avctx, AVPacket *avpkt,
                                                      10);
         if(!side_data) {
             av_packet_unref(avpkt);
-            av_free(avpkt);
             return AVERROR(ENOMEM);
         }
         AV_WL32(side_data + 4, discard_padding);