[FFmpeg-cvslog] avcodec/pgssubdec: Remove redundant freeing code

Andreas Rheinhardt git at videolan.org
Thu Dec 16 04:01:51 EET 2021


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Fri Dec 10 21:02:47 2021 +0100| [58228ab9b91a6a6e418fd38942aa84b6fffa7df9] | committer: Andreas Rheinhardt

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 at outlook.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=58228ab9b91a6a6e418fd38942aa84b6fffa7df9
---

 libavcodec/pgssubdec.c | 17 ++++-------------
 1 file 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));



More information about the ffmpeg-cvslog mailing list