]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/agm.c
avcodec/nvenc: add driver version info for SDK 9.1
[ffmpeg] / libavcodec / agm.c
index 7dcfaff4adc8ca9ec50baecabd03391e464c38cd..2c4c9805e90031843aeb498f6da73a4485a41181 100644 (file)
@@ -103,6 +103,9 @@ static int read_code(GetBitContext *gb, int *oskip, int *level, int *map, int mo
 {
     int len = 0, skip = 0, max;
 
+    if (get_bits_left(gb) < 2)
+        return AVERROR_INVALIDDATA;
+
     if (show_bits(gb, 2)) {
         switch (show_bits(gb, 4)) {
         case 1:
@@ -915,7 +918,7 @@ static void get_tree_codes(uint32_t *codes, Node *nodes, int idx, uint32_t pfx,
         codes[idx] = pfx;
     } else if (idx >= 0) {
         get_tree_codes(codes, nodes, nodes[idx].child[0], pfx + (0 << bitpos), bitpos + 1);
-        get_tree_codes(codes, nodes, nodes[idx].child[1], pfx + (1 << bitpos), bitpos + 1);
+        get_tree_codes(codes, nodes, nodes[idx].child[1], pfx + (1U << bitpos), bitpos + 1);
     }
 }
 
@@ -1046,6 +1049,9 @@ static int decode_huffman2(AVCodecContext *avctx, int header, int size)
 
     s->output_size = get_bits_long(gb, 32);
 
+    if (s->output_size > avctx->width * avctx->height * 9LL + 10000)
+        return AVERROR_INVALIDDATA;
+
     av_fast_padded_malloc(&s->output, &s->padded_output_size, s->output_size);
     if (!s->output)
         return AVERROR(ENOMEM);