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