diff options
author | Anton Khirnov <anton@khirnov.net> | 2022-11-27 10:45:15 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2023-01-04 11:48:17 +0100 |
commit | cccd2c2179ec9f51bc0db3ab64a525a50c8024a5 (patch) | |
tree | 12e1fd3ed7d37e37de1689a9740f119d9109943f /libavcodec | |
parent | 87eb3626938be9d33080fdc0c0a6021ba5eaa6df (diff) | |
download | ffmpeg-cccd2c2179ec9f51bc0db3ab64a525a50c8024a5.tar.gz |
lavc/libx264: unify cleanup in setup_frame()
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/libx264.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 1e9ca73cdf..f776d65588 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -489,10 +489,8 @@ static int setup_frame(AVCodecContext *ctx, const AVFrame *frame, sd = av_frame_get_side_data(frame, AV_FRAME_DATA_REGIONS_OF_INTEREST); if (sd) { ret = setup_roi(ctx, pic, bit_depth, frame, sd->data, sd->size); - if (ret < 0) { - free_picture(ctx); - return ret; - } + if (ret < 0) + goto fail; } if (x4->udu_sei) { @@ -504,16 +502,16 @@ static int setup_frame(AVCodecContext *ctx, const AVFrame *frame, continue; tmp = av_fast_realloc(sei->payloads, &sei_data_size, (sei->num_payloads + 1) * sizeof(*sei_payload)); if (!tmp) { - free_picture(ctx); - return AVERROR(ENOMEM); + ret = AVERROR(ENOMEM); + goto fail; } sei->payloads = tmp; sei->sei_free = av_free; sei_payload = &sei->payloads[sei->num_payloads]; sei_payload->payload = av_memdup(side_data->data, side_data->size); if (!sei_payload->payload) { - free_picture(ctx); - return AVERROR(ENOMEM); + ret = AVERROR(ENOMEM); + goto fail; } sei_payload->payload_size = side_data->size; sei_payload->payload_type = SEI_TYPE_USER_DATA_UNREGISTERED; @@ -523,6 +521,11 @@ static int setup_frame(AVCodecContext *ctx, const AVFrame *frame, *ppic = pic; return 0; + +fail: + free_picture(ctx); + *ppic = NULL; + return ret; } static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame, |