Move av_malloc() after the check for subsampling to avoid memory leak if subsampling < 0 and av_malloc() succeeds.
Showing the changes to libavcodec (1 of 1 file). Show all
Unified · Split
| @@ -71,12 +71,12 @@ CFDataRef ff_videotoolbox_vpcc_extradata_create(AVCodecContext *avctx) · 70 unmodified lines | ||
| 71 | 71 | uint8_t *vt_extradata; |
| 72 | 72 | int subsampling = get_vpx_chroma_subsampling(avctx->sw_pix_fmt, avctx->chroma_sample_location); |
| 73 | 73 | |
| 74 | − vt_extradata_size = 1 + 3 + 6 + 2; | |
| 75 | − vt_extradata = av_malloc(vt_extradata_size); | |
| 76 | − | |
| 77 | 74 | if (subsampling < 0) |
| 78 | 75 | return NULL; |
| 79 | 76 | |
| 77 | + vt_extradata_size = 1 + 3 + 6 + 2; | |
| 78 | + vt_extradata = av_malloc(vt_extradata_size); | |
| 79 | + | |
| 80 | 80 | if (!vt_extradata) |
| 81 | 81 | return NULL; |
| 82 | 82 | |