Browse Source

avcodec/pgssubdec: do not fail when part of the packet is faulty unless AV_EF_EXPLODE is set

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
tags/n2.3
John Stebbins Michael Niedermayer 11 years ago
parent
commit
ca7f2a7372
1 changed files with 11 additions and 6 deletions
  1. +11
    -6
      libavcodec/pgssubdec.c

+ 11
- 6
libavcodec/pgssubdec.c View File

@@ -254,7 +254,7 @@ static int parse_picture_segment(AVCodecContext *avctx,
* @param buf pointer to the packet to process * @param buf pointer to the packet to process
* @param buf_size size of packet to process * @param buf_size size of packet to process
*/ */
static void parse_palette_segment(AVCodecContext *avctx,
static int parse_palette_segment(AVCodecContext *avctx,
const uint8_t *buf, int buf_size) const uint8_t *buf, int buf_size)
{ {
PGSSubContext *ctx = avctx->priv_data; PGSSubContext *ctx = avctx->priv_data;
@@ -283,6 +283,7 @@ static void parse_palette_segment(AVCodecContext *avctx,
/* Store color in palette */ /* Store color in palette */
ctx->clut[color_id] = RGBA(r,g,b,alpha); ctx->clut[color_id] = RGBA(r,g,b,alpha);
} }
return 0;
} }


/** /**
@@ -493,17 +494,16 @@ static int decode(AVCodecContext *avctx, void *data, int *data_size,
if (segment_type != DISPLAY_SEGMENT && segment_length > buf_end - buf) if (segment_type != DISPLAY_SEGMENT && segment_length > buf_end - buf)
break; break;


ret = 0;
switch (segment_type) { switch (segment_type) {
case PALETTE_SEGMENT: case PALETTE_SEGMENT:
parse_palette_segment(avctx, buf, segment_length);
ret = parse_palette_segment(avctx, buf, segment_length);
break; break;
case OBJECT_SEGMENT: case OBJECT_SEGMENT:
parse_picture_segment(avctx, buf, segment_length);
ret = parse_picture_segment(avctx, buf, segment_length);
break; break;
case PRESENTATION_SEGMENT: case PRESENTATION_SEGMENT:
ret = parse_presentation_segment(avctx, buf, segment_length, sub->pts); ret = parse_presentation_segment(avctx, buf, segment_length, sub->pts);
if (ret < 0)
return ret;
break; break;
case WINDOW_SEGMENT: case WINDOW_SEGMENT:
/* /*
@@ -516,13 +516,18 @@ static int decode(AVCodecContext *avctx, void *data, int *data_size,
*/ */
break; break;
case DISPLAY_SEGMENT: case DISPLAY_SEGMENT:
*data_size = display_end_segment(avctx, data, buf, segment_length);
ret = display_end_segment(avctx, data, buf, segment_length);
if (ret >= 0)
*data_size = ret;
break; break;
default: default:
av_log(avctx, AV_LOG_ERROR, "Unknown subtitle segment type 0x%x, length %d\n", av_log(avctx, AV_LOG_ERROR, "Unknown subtitle segment type 0x%x, length %d\n",
segment_type, segment_length); segment_type, segment_length);
ret = AVERROR_INVALIDDATA;
break; break;
} }
if (ret < 0 && (avctx->err_recognition & AV_EF_EXPLODE))
return ret;


buf += segment_length; buf += segment_length;
} }


Loading…
Cancel
Save