Commit 1bf747ae authored by Michael Niedermayer's avatar Michael Niedermayer

avcodec/dvbsubdec: Return proper error codes from more functions

Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent ebe3a41e
...@@ -1149,7 +1149,7 @@ static int dvbsub_parse_clut_segment(AVCodecContext *avctx, ...@@ -1149,7 +1149,7 @@ static int dvbsub_parse_clut_segment(AVCodecContext *avctx,
} }
static void dvbsub_parse_region_segment(AVCodecContext *avctx, static int dvbsub_parse_region_segment(AVCodecContext *avctx,
const uint8_t *buf, int buf_size) const uint8_t *buf, int buf_size)
{ {
DVBSubContext *ctx = avctx->priv_data; DVBSubContext *ctx = avctx->priv_data;
...@@ -1163,7 +1163,7 @@ static void dvbsub_parse_region_segment(AVCodecContext *avctx, ...@@ -1163,7 +1163,7 @@ static void dvbsub_parse_region_segment(AVCodecContext *avctx,
int fill; int fill;
if (buf_size < 10) if (buf_size < 10)
return; return AVERROR_INVALIDDATA;
region_id = *buf++; region_id = *buf++;
...@@ -1172,7 +1172,7 @@ static void dvbsub_parse_region_segment(AVCodecContext *avctx, ...@@ -1172,7 +1172,7 @@ static void dvbsub_parse_region_segment(AVCodecContext *avctx,
if (!region) { if (!region) {
region = av_mallocz(sizeof(DVBSubRegion)); region = av_mallocz(sizeof(DVBSubRegion));
if (!region) if (!region)
return; return AVERROR(ENOMEM);
region->id = region_id; region->id = region_id;
region->version = -1; region->version = -1;
...@@ -1265,9 +1265,11 @@ static void dvbsub_parse_region_segment(AVCodecContext *avctx, ...@@ -1265,9 +1265,11 @@ static void dvbsub_parse_region_segment(AVCodecContext *avctx,
display->object_list_next = object->display_list; display->object_list_next = object->display_list;
object->display_list = display; object->display_list = display;
} }
return 0;
} }
static void dvbsub_parse_page_segment(AVCodecContext *avctx, static int dvbsub_parse_page_segment(AVCodecContext *avctx,
const uint8_t *buf, int buf_size, AVSubtitle *sub, int *got_output) const uint8_t *buf, int buf_size, AVSubtitle *sub, int *got_output)
{ {
DVBSubContext *ctx = avctx->priv_data; DVBSubContext *ctx = avctx->priv_data;
...@@ -1281,14 +1283,14 @@ static void dvbsub_parse_page_segment(AVCodecContext *avctx, ...@@ -1281,14 +1283,14 @@ static void dvbsub_parse_page_segment(AVCodecContext *avctx,
int version; int version;
if (buf_size < 1) if (buf_size < 1)
return; return AVERROR_INVALIDDATA;
timeout = *buf++; timeout = *buf++;
version = ((*buf)>>4) & 15; version = ((*buf)>>4) & 15;
page_state = ((*buf++) >> 2) & 3; page_state = ((*buf++) >> 2) & 3;
if (ctx->version == version) { if (ctx->version == version) {
return; return 0;
} }
ctx->time_out = timeout; ctx->time_out = timeout;
...@@ -1346,6 +1348,7 @@ static void dvbsub_parse_page_segment(AVCodecContext *avctx, ...@@ -1346,6 +1348,7 @@ static void dvbsub_parse_page_segment(AVCodecContext *avctx,
av_freep(&display); av_freep(&display);
} }
return 0;
} }
...@@ -1444,7 +1447,7 @@ static void save_display_set(DVBSubContext *ctx) ...@@ -1444,7 +1447,7 @@ static void save_display_set(DVBSubContext *ctx)
} }
#endif #endif
static void dvbsub_parse_display_definition_segment(AVCodecContext *avctx, static int dvbsub_parse_display_definition_segment(AVCodecContext *avctx,
const uint8_t *buf, const uint8_t *buf,
int buf_size) int buf_size)
{ {
...@@ -1453,19 +1456,19 @@ static void dvbsub_parse_display_definition_segment(AVCodecContext *avctx, ...@@ -1453,19 +1456,19 @@ static void dvbsub_parse_display_definition_segment(AVCodecContext *avctx,
int dds_version, info_byte; int dds_version, info_byte;
if (buf_size < 5) if (buf_size < 5)
return; return AVERROR_INVALIDDATA;
info_byte = bytestream_get_byte(&buf); info_byte = bytestream_get_byte(&buf);
dds_version = info_byte >> 4; dds_version = info_byte >> 4;
if (display_def && display_def->version == dds_version) if (display_def && display_def->version == dds_version)
return; // already have this display definition version return 0; // already have this display definition version
if (!display_def) { if (!display_def) {
display_def = av_mallocz(sizeof(*display_def)); display_def = av_mallocz(sizeof(*display_def));
ctx->display_definition = display_def; ctx->display_definition = display_def;
} }
if (!display_def) if (!display_def)
return; return AVERROR(ENOMEM);
display_def->version = dds_version; display_def->version = dds_version;
display_def->x = 0; display_def->x = 0;
...@@ -1478,7 +1481,7 @@ static void dvbsub_parse_display_definition_segment(AVCodecContext *avctx, ...@@ -1478,7 +1481,7 @@ static void dvbsub_parse_display_definition_segment(AVCodecContext *avctx,
} }
if (buf_size < 13) if (buf_size < 13)
return; return 0;
if (info_byte & 1<<3) { // display_window_flag if (info_byte & 1<<3) { // display_window_flag
display_def->x = bytestream_get_be16(&buf); display_def->x = bytestream_get_be16(&buf);
...@@ -1486,6 +1489,8 @@ static void dvbsub_parse_display_definition_segment(AVCodecContext *avctx, ...@@ -1486,6 +1489,8 @@ static void dvbsub_parse_display_definition_segment(AVCodecContext *avctx,
display_def->y = bytestream_get_be16(&buf); display_def->y = bytestream_get_be16(&buf);
display_def->height = bytestream_get_be16(&buf) - display_def->y + 1; display_def->height = bytestream_get_be16(&buf) - display_def->y + 1;
} }
return 0;
} }
static void dvbsub_display_end_segment(AVCodecContext *avctx, const uint8_t *buf, static void dvbsub_display_end_segment(AVCodecContext *avctx, const uint8_t *buf,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment