1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-04 22:03:09 +02:00

avcodec/tests/avpacket: Add av_packet_free() to avoid memory leak

Add av_packet_free() to free avpkt_clone and avpkt in the error paths to avoid potential memory leak.

Fixes: da3c69a5a9 ("Added test for libavcodec/avpacket.c")
Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Jiasheng Jiang
2025-08-03 20:09:38 +00:00
committed by Michael Niedermayer
parent 008679ec16
commit ab040e2565

View File

@ -102,11 +102,14 @@ int main(void)
if(!avpkt_clone) { if(!avpkt_clone) {
av_log(NULL, AV_LOG_ERROR,"av_packet_clone failed to clone AVPacket\n"); av_log(NULL, AV_LOG_ERROR,"av_packet_clone failed to clone AVPacket\n");
av_packet_free(&avpkt);
return 1; return 1;
} }
/*test av_grow_packet*/ /*test av_grow_packet*/
if(av_grow_packet(avpkt_clone, 20) < 0){ if(av_grow_packet(avpkt_clone, 20) < 0){
av_log(NULL, AV_LOG_ERROR, "av_grow_packet failed\n"); av_log(NULL, AV_LOG_ERROR, "av_grow_packet failed\n");
av_packet_free(&avpkt_clone);
av_packet_free(&avpkt);
return 1; return 1;
} }
if(av_grow_packet(avpkt_clone, INT_MAX) == 0){ if(av_grow_packet(avpkt_clone, INT_MAX) == 0){