mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 02:00:05 +00:00 
			
		
		
		
	Avoid overflow when getting data level code or value
This commit is contained in:
		
							parent
							
								
									66b7bd36fe
								
							
						
					
					
						commit
						a652ac460b
					
				
					 1 changed files with 2 additions and 2 deletions
				
			
		|  | @ -884,7 +884,7 @@ ProductDescriptionBlock::data_level_code(std::uint8_t level) const | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    // Different products use different scale/offset formulas
 |    // Different products use different scale/offset formulas
 | ||||||
|    if (number_of_levels() <= 16 && p->productCode_ != 34) |    if (number_of_levels() <= 16 && p->productCode_ != 34 && level < 16) | ||||||
|    { |    { | ||||||
|       uint16_t th = data_level_threshold(level); |       uint16_t th = data_level_threshold(level); | ||||||
|       if ((th & 0x8000u)) |       if ((th & 0x8000u)) | ||||||
|  | @ -976,7 +976,7 @@ ProductDescriptionBlock::data_value(std::uint8_t level) const | ||||||
|          break; |          break; | ||||||
|       } |       } | ||||||
|    } |    } | ||||||
|    else |    else if (level < 16) | ||||||
|    { |    { | ||||||
|       std::uint16_t th = data_level_threshold(level); |       std::uint16_t th = data_level_threshold(level); | ||||||
|       if ((th & 0x8000u) == 0) |       if ((th & 0x8000u) == 0) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat