Add av_packet_free() to free avpkt_clone and avpkt in the error paths to avoid potential memory leak.
Unified · Split
| @@ -102,11 +102,14 @@ int main(void) · 101 unmodified lines | |||
| 102 | 102 | ||
| 103 | if(!avpkt_clone) { | 103 | if(!avpkt_clone) { |
| 104 | av_log(NULL, AV_LOG_ERROR,"av_packet_clone failed to clone AVPacket\n"); | 104 | av_log(NULL, AV_LOG_ERROR,"av_packet_clone failed to clone AVPacket\n"); |
| 105 | av_packet_free(&avpkt); | ||
| 105 | return 1; | 106 | return 1; |
| 106 | } | 107 | } |
| 107 | /*test av_grow_packet*/ | 108 | /*test av_grow_packet*/ |
| 108 | if(av_grow_packet(avpkt_clone, 20) < 0){ | 109 | if(av_grow_packet(avpkt_clone, 20) < 0){ |
| 109 | av_log(NULL, AV_LOG_ERROR, "av_grow_packet failed\n"); | 110 | av_log(NULL, AV_LOG_ERROR, "av_grow_packet failed\n"); |
| 111 | av_packet_free(&avpkt_clone); | ||
| 112 | av_packet_free(&avpkt); | ||
| 110 | return 1; | 113 | return 1; |
| 111 | } | 114 | } |
| 112 | if(av_grow_packet(avpkt_clone, INT_MAX) == 0){ | 115 | if(av_grow_packet(avpkt_clone, INT_MAX) == 0){ |