]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/dvdsub_parser.c
avdevice/avdevice: Constify avdevice_list_input_sources/output_sinks
[ffmpeg] / libavcodec / dvdsub_parser.c
index 8e1c48bef63db7bef84c43a8b0d1b09f3ad4ce97..054af69db9eb6e96572ca869a9e384a7c4277231 100644 (file)
@@ -32,11 +32,6 @@ typedef struct DVDSubParseContext {
     int packet_index;
 } DVDSubParseContext;
 
-static av_cold int dvdsub_parse_init(AVCodecParserContext *s)
-{
-    return 0;
-}
-
 static int dvdsub_parse(AVCodecParserContext *s,
                         AVCodecContext *avctx,
                         const uint8_t **poutbuf, int *poutbuf_size,
@@ -57,7 +52,11 @@ static int dvdsub_parse(AVCodecParserContext *s,
         if (pc->packet_len == 0) /* HD-DVD subpicture packet */
             pc->packet_len = AV_RB32(buf+2);
         av_freep(&pc->packet);
-        pc->packet = av_malloc(pc->packet_len);
+        if ((unsigned)pc->packet_len > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE) {
+            av_log(avctx, AV_LOG_ERROR, "packet length %d is invalid\n", pc->packet_len);
+            return buf_size;
+        }
+        pc->packet = av_malloc(pc->packet_len + AV_INPUT_BUFFER_PADDING_SIZE);
     }
     if (pc->packet) {
         if (pc->packet_index + buf_size <= pc->packet_len) {
@@ -88,7 +87,6 @@ static av_cold void dvdsub_parse_close(AVCodecParserContext *s)
 AVCodecParser ff_dvdsub_parser = {
     .codec_ids      = { AV_CODEC_ID_DVD_SUBTITLE },
     .priv_data_size = sizeof(DVDSubParseContext),
-    .parser_init    = dvdsub_parse_init,
     .parser_parse   = dvdsub_parse,
     .parser_close   = dvdsub_parse_close,
 };