]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/notchlc.c
avcodec: Constify AVCodecs
[ffmpeg] / libavcodec / notchlc.c
index f9e03fdded9087592a2e4bd10f3623881aa962fe..c109c5f6f313c9515522b304ff236b5cf8a50617 100644 (file)
@@ -108,8 +108,7 @@ static int lz4_decompress(AVCodecContext *avctx,
         if (bytestream2_get_bytes_left(gb) <= 0)
             break;
 
-        delta = bytestream2_get_byte(gb);
-        delta |= (unsigned)bytestream2_get_byte(gb) << 8;
+        delta = bytestream2_get_le16(gb);
         if (delta == 0)
             return 0;
         match_length = 4 + (token & 0x0F);
@@ -230,6 +229,9 @@ static int decode_blocks(AVCodecContext *avctx, AVFrame *p, ThreadFrame *frame,
     bytestream2_seek(&rgb, s->y_data_row_offsets, SEEK_SET);
     bytestream2_seek(gb, s->y_control_data_offset, SEEK_SET);
 
+    if (bytestream2_get_bytes_left(gb) < (avctx->height + 3) / 4 * ((avctx->width + 3) / 4) * 4)
+        return AVERROR_INVALIDDATA;
+
     dsty = (uint16_t *)p->data[0];
     dsta = (uint16_t *)p->data[3];
     ylinesize = p->linesize[0] / 2;
@@ -278,6 +280,9 @@ static int decode_blocks(AVCodecContext *avctx, AVFrame *p, ThreadFrame *frame,
             dsta += alinesize;
         }
     } else {
+        if (bytestream2_get_bytes_left(gb) < (avctx->height + 15) / 16 * ((avctx->width + 15) / 16) * 8)
+            return AVERROR_INVALIDDATA;
+
         for (int y = 0; y < avctx->height; y += 16) {
             for (int x = 0; x < avctx->width; x += 16) {
                 unsigned m = bytestream2_get_le32(gb);
@@ -491,6 +496,9 @@ static int decode_frame(AVCodecContext *avctx,
 
         bytestream2_init(gb, s->lzf_buffer, uncompressed_size);
     } else if (s->format == 1) {
+        if (bytestream2_get_bytes_left(gb) < uncompressed_size / 255)
+            return AVERROR_INVALIDDATA;
+
         av_fast_padded_malloc(&s->uncompressed_buffer, &s->uncompressed_size,
                               uncompressed_size);
         if (!s->uncompressed_buffer)
@@ -529,7 +537,7 @@ static av_cold int decode_end(AVCodecContext *avctx)
     return 0;
 }
 
-AVCodec ff_notchlc_decoder = {
+const AVCodec ff_notchlc_decoder = {
     .name             = "notchlc",
     .long_name        = NULL_IF_CONFIG_SMALL("NotchLC"),
     .type             = AVMEDIA_TYPE_VIDEO,