diff options
author | Vittorio Giovara <vittorio.giovara@gmail.com> | 2017-06-13 11:35:16 -0400 |
---|---|---|
committer | Vittorio Giovara <vittorio.giovara@gmail.com> | 2017-06-28 09:44:09 -0400 |
commit | a594f17f83a1ffdc1eec18818208fe39487dd5d7 (patch) | |
tree | 3ae3199223d50454c34d035fdac8d3396d35a135 | |
parent | 1cfd566324f4a9be066ea400685b81c0695e64d9 (diff) | |
download | ffmpeg-streaming-a594f17f83a1ffdc1eec18818208fe39487dd5d7.zip ffmpeg-streaming-a594f17f83a1ffdc1eec18818208fe39487dd5d7.tar.gz |
dvbsubdec: Free subrect memory on allocation error
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
-rw-r--r-- | libavcodec/dvbsubdec.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c index 63523b7..b97ff80 100644 --- a/libavcodec/dvbsubdec.c +++ b/libavcodec/dvbsubdec.c @@ -1293,6 +1293,10 @@ static int dvbsub_display_end_segment(AVCodecContext *avctx, const uint8_t *buf, for (i = 0; i < sub->num_rects; i++) { sub->rects[i] = av_mallocz(sizeof(*sub->rects[i])); if (!sub->rects[i]) { + int j; + for (j = 0; j < i; j ++) + av_free(sub->rects[j]); + av_free(sub->rects); return AVERROR(ENOMEM); } } @@ -1335,6 +1339,8 @@ static int dvbsub_display_end_segment(AVCodecContext *avctx, const uint8_t *buf, rect->data[1] = av_mallocz(AVPALETTE_SIZE); if (!rect->data[1]) { + for (i = 0; i < sub->num_rects; i++) + av_free(sub->rects[i]); av_free(sub->rects); return AVERROR(ENOMEM); } @@ -1343,6 +1349,8 @@ static int dvbsub_display_end_segment(AVCodecContext *avctx, const uint8_t *buf, rect->data[0] = av_malloc(region->buf_size); if (!rect->data[0]) { av_free(rect->data[1]); + for (i = 0; i < sub->num_rects; i++) + av_free(sub->rects[i]); av_free(sub->rects); return AVERROR(ENOMEM); } |