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