Merge pull request #1422 from nh2/fix-potential-hash-comparison-crash
Fix potential crash/wrong result two hashes of unequal length are compared
This commit is contained in:
		
						commit
						9c00fa4179
					
				
					 1 changed files with 2 additions and 0 deletions
				
			
		| 
						 | 
					@ -45,6 +45,8 @@ bool Hash::operator != (const Hash & h2) const
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool Hash::operator < (const Hash & h) const
 | 
					bool Hash::operator < (const Hash & h) const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    if (hashSize < h.hashSize) return true;
 | 
				
			||||||
 | 
					    if (hashSize > h.hashSize) return false;
 | 
				
			||||||
    for (unsigned int i = 0; i < hashSize; i++) {
 | 
					    for (unsigned int i = 0; i < hashSize; i++) {
 | 
				
			||||||
        if (hash[i] < h.hash[i]) return true;
 | 
					        if (hash[i] < h.hash[i]) return true;
 | 
				
			||||||
        if (hash[i] > h.hash[i]) return false;
 | 
					        if (hash[i] > h.hash[i]) return false;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue