video/readers/jpeg: Do not reallocate a given huff table

Fix a memory leak where an invalid file could cause us to reallocate
memory for a huffman table we had already allocated memory for.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
Daniel Axtens authored and Daniel Kiper committed 2022-06-07 16:39:32 +02:00
1 parent d5caac8ab7
commit 768ef2199e
1 file changed
+3
+3
View File
@@ -251,6 +251,9 @@ grub_jpeg_decode_huff_table (struct grub_jpeg_data *data)
n += count[i];
id += ac * 2;
if (data->huff_value[id] != NULL)
return grub_error (GRUB_ERR_BAD_FILE_TYPE,
"jpeg: attempt to reallocate huffman table");
data->huff_value[id] = grub_malloc (n);
if (grub_errno)
return grub_errno;