From e5aed07ec15f151a5b3bad19b610b80f0a2e2e20 Mon Sep 17 00:00:00 2001 From: Masahiro Hanada Date: Thu, 14 Sep 2023 19:37:24 +0900 Subject: [PATCH] [libwebp] Fix next is invalid pointer when WebPSafeMalloc fails When WebPSafeMalloc fails on VP8LHuffmanTablesAllocate, next is not initialized to NULL. VP8LHuffmanTablesDeallocate uses next to know the following nodes. A patch fixes this issue. Change-Id: I144ae84cd97e5bca227018ef1afa95361267902c --- media/libwebp/utils/huffman_utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media/libwebp/utils/huffman_utils.c b/media/libwebp/utils/huffman_utils.c index 7b57b9c52f..dd80022213 100644 --- a/media/libwebp/utils/huffman_utils.c +++ b/media/libwebp/utils/huffman_utils.c @@ -267,11 +267,11 @@ int VP8LHuffmanTablesAllocate(int size, HuffmanTables* huffman_tables) { // Have 'segment' point to the first segment for now, 'root'. HuffmanTablesSegment* const root = &huffman_tables->root; huffman_tables->curr_segment = root; + root->next = NULL; // Allocate root. root->start = (HuffmanCode*)WebPSafeMalloc(size, sizeof(*root->start)); if (root->start == NULL) return 0; root->curr_table = root->start; - root->next = NULL; root->size = size; return 1; }