mirror of
				https://github.com/webmproject/libwebp.git
				synced 2025-10-31 10:25:46 +01:00 
			
		
		
		
	Add fbounds-safety annotations for code_lengths.
				
					
				
			Reasoning: The compiler reported an error in `src/utils/huffman_utils.c` at line 230 because the array parameter `code_lengths` decayed to a `__single` pointer, which disallows pointer arithmetic. The parameter `code_lengths_size` represents the size of the `code_lengths` array. To fix this, the `code_lengths` parameter in the definition of `VP8LBuildHuffmanTable` (line 230) and its declaration in `src/utils/huffman_utils.h` (line 108) were annotated with `WEBP_COUNTED_BY(code_lengths_size)`. Bug: 432511821 Change-Id: Id0b32ca283bba5938320abbdbe61846e2d538c5d
This commit is contained in:
		| @@ -227,7 +227,9 @@ static int BuildHuffmanTable(HuffmanCode* const root_table, int root_bits, | |||||||
| // Cut-off value for switching between heap and stack allocation. | // Cut-off value for switching between heap and stack allocation. | ||||||
| #define SORTED_SIZE_CUTOFF 512 | #define SORTED_SIZE_CUTOFF 512 | ||||||
| int VP8LBuildHuffmanTable(HuffmanTables* const root_table, int root_bits, | int VP8LBuildHuffmanTable(HuffmanTables* const root_table, int root_bits, | ||||||
|                           const int code_lengths[], int code_lengths_size) { |                           const int WEBP_COUNTED_BY(code_lengths_size) | ||||||
|  |                               code_lengths[], | ||||||
|  |                           int code_lengths_size) { | ||||||
|   const int total_size = |   const int total_size = | ||||||
|       BuildHuffmanTable(NULL, root_bits, code_lengths, code_lengths_size, NULL); |       BuildHuffmanTable(NULL, root_bits, code_lengths, code_lengths_size, NULL); | ||||||
|   assert(code_lengths_size <= MAX_CODE_LENGTHS_SIZE); |   assert(code_lengths_size <= MAX_CODE_LENGTHS_SIZE); | ||||||
|   | |||||||
| @@ -105,9 +105,9 @@ void VP8LHtreeGroupsFree(HTreeGroup* const htree_groups); | |||||||
| // the huffman table. | // the huffman table. | ||||||
| // Returns built table size or 0 in case of error (invalid tree or | // Returns built table size or 0 in case of error (invalid tree or | ||||||
| // memory error). | // memory error). | ||||||
| WEBP_NODISCARD int VP8LBuildHuffmanTable(HuffmanTables* const root_table, | WEBP_NODISCARD int VP8LBuildHuffmanTable( | ||||||
|                                          int root_bits, |     HuffmanTables* const root_table, int root_bits, | ||||||
|                                          const int code_lengths[], |     const int WEBP_COUNTED_BY(code_lengths_size) code_lengths[], | ||||||
|     int code_lengths_size); |     int code_lengths_size); | ||||||
|  |  | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user