mirror of
				https://github.com/webmproject/libwebp.git
				synced 2025-10-31 10:25:46 +01:00 
			
		
		
		
	BuildHuffmanTable: add an assert for offset[] bounds
And provide a clear comment explaining why the index of offset[] is always checked within bounds. Bug:webp:622 Change-Id: Id9b973a804b74c53dfb291f1a9dae649c0daed9d
This commit is contained in:
		
				
					committed by
					
						 James Zern
						James Zern
					
				
			
			
				
	
			
			
			
						parent
						
							85e098e58d
						
					
				
				
					commit
					fa6f56496a
				
			| @@ -124,6 +124,10 @@ static int BuildHuffmanTable(HuffmanCode* const root_table, int root_bits, | ||||
|     const int symbol_code_length = code_lengths[symbol]; | ||||
|     if (code_lengths[symbol] > 0) { | ||||
|       if (sorted != NULL) { | ||||
|         assert(offset[symbol_code_length] < code_lengths_size); | ||||
|         // The following check is not redundant with the assert. It prevents a | ||||
|         // potential buffer overflow that the optimizer might not be able to | ||||
|         // rule out on its own. | ||||
|         if (offset[symbol_code_length] >= code_lengths_size) { | ||||
|           return 0; | ||||
|         } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user