[FFmpeg-devel] [PATCH] Check av_dup_packet() return code

Andreas Cadhalpun andreas.cadhalpun at googlemail.com
Wed Feb 3 23:27:00 CET 2016


On 03.02.2016 19:05, Michael Niedermayer wrote:
> Fixes: CID1338320
> 
> Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> ---
>  libavcodec/frame_thread_encoder.c |    4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/frame_thread_encoder.c b/libavcodec/frame_thread_encoder.c
> index 04c9a0e..27ae356 100644
> --- a/libavcodec/frame_thread_encoder.c
> +++ b/libavcodec/frame_thread_encoder.c
> @@ -89,7 +89,9 @@ static void * attribute_align_arg worker(void *v){
>          pthread_mutex_unlock(&c->buffer_mutex);
>          av_frame_free(&frame);
>          if(got_packet) {
> -            av_dup_packet(pkt);
> +            int ret2 = av_dup_packet(pkt);
> +            if (ret >= 0 && ret2 < 0)
> +                ret = ret2;
>          } else {
>              pkt->data = NULL;
>              pkt->size = 0;
> 

Checking the return code this way is probably OK, but maybe you can also replace the
deprecated av_dup_packet with av_packet_ref while at it?

Best regards,
Andreas


More information about the ffmpeg-devel mailing list