summaryrefslogtreecommitdiff
path: root/libavcodec/pgssubdec.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-12-10 21:02:47 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-12-16 02:37:26 +0100
commit58228ab9b91a6a6e418fd38942aa84b6fffa7df9 (patch)
tree833e07db951ab12abc5bf1c5c0e123925ca037f2 /libavcodec/pgssubdec.c
parent200a3728373fbc74cbfdfcbb3d2152cf21d17034 (diff)
downloadffmpeg-58228ab9b91a6a6e418fd38942aa84b6fffa7df9.tar.gz
avcodec/pgssubdec: Remove redundant freeing code
The caller of display_end_segment() frees the AVSubtitle on error in case ENOMEM is returned or err_recognition is set to explode, so display_end_segment() doesn't have to. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/pgssubdec.c')
-rw-r--r--libavcodec/pgssubdec.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/libavcodec/pgssubdec.c b/libavcodec/pgssubdec.c
index 2d5700a51e..d2824f5bbf 100644
--- a/libavcodec/pgssubdec.c
+++ b/libavcodec/pgssubdec.c
@@ -534,10 +534,8 @@ static int display_end_segment(AVCodecContext *avctx, void *data,
PGSSubObject *object;
sub->rects[i] = av_mallocz(sizeof(*sub->rects[0]));
- if (!sub->rects[i]) {
- avsubtitle_free(sub);
+ if (!sub->rects[i])
return AVERROR(ENOMEM);
- }
sub->num_rects++;
sub->rects[i]->type = SUBTITLE_BITMAP;
@@ -547,10 +545,8 @@ static int display_end_segment(AVCodecContext *avctx, void *data,
// Missing object. Should only happen with damaged streams.
av_log(avctx, AV_LOG_ERROR, "Invalid object id %d\n",
ctx->presentation.objects[i].id);
- if (avctx->err_recognition & AV_EF_EXPLODE) {
- avsubtitle_free(sub);
+ if (avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
- }
// Leaves rect empty with 0 width and height.
continue;
}
@@ -569,16 +565,13 @@ static int display_end_segment(AVCodecContext *avctx, void *data,
if (object->rle_remaining_len) {
av_log(avctx, AV_LOG_ERROR, "RLE data length %u is %u bytes shorter than expected\n",
object->rle_data_len, object->rle_remaining_len);
- if (avctx->err_recognition & AV_EF_EXPLODE) {
- avsubtitle_free(sub);
+ if (avctx->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
- }
}
ret = decode_rle(avctx, sub->rects[i], object->rle, object->rle_data_len);
if (ret < 0) {
if ((avctx->err_recognition & AV_EF_EXPLODE) ||
ret == AVERROR(ENOMEM)) {
- avsubtitle_free(sub);
return ret;
}
sub->rects[i]->w = 0;
@@ -589,10 +582,8 @@ static int display_end_segment(AVCodecContext *avctx, void *data,
/* Allocate memory for colors */
sub->rects[i]->nb_colors = 256;
sub->rects[i]->data[1] = av_mallocz(AVPALETTE_SIZE);
- if (!sub->rects[i]->data[1]) {
- avsubtitle_free(sub);
+ if (!sub->rects[i]->data[1])
return AVERROR(ENOMEM);
- }
if (!ctx->forced_subs_only || ctx->presentation.objects[i].composition_flag & 0x40)
memcpy(sub->rects[i]->data[1], palette->clut, sub->rects[i]->nb_colors * sizeof(uint32_t));