Fix issues in botan shown up by a coverity scan

Reviewed-by: kh
This commit is contained in:
Bill King
2010-05-27 12:15:53 +02:00
parent ed018f691a
commit b201dcb584
3 changed files with 5 additions and 3 deletions

View File

@@ -180,7 +180,7 @@ void Pooling_Allocator::deallocate(void* ptr, u32bit n)
const u32bit BITMAP_SIZE = Memory_Block::bitmap_size();
const u32bit BLOCK_SIZE = Memory_Block::block_size();
if(ptr == 0 && n == 0)
if(ptr == 0 || n == 0)
return;
Mutex_Holder lock(mutex);

View File

@@ -103,8 +103,9 @@ EMSA2::EMSA2(HashFunction* hash_in) : hash(hash_in)
if(hash_id == 0)
{
std::string hashname = hash->name();
delete hash;
throw Encoding_Error("EMSA2 cannot be used with " + hash->name());
throw Encoding_Error("EMSA2 cannot be used with " + hashname);
}
}

View File

@@ -186,10 +186,11 @@ Randpool::Randpool(BlockCipher* cipher_in,
!cipher->valid_keylength(OUTPUT_LENGTH) ||
!mac->valid_keylength(OUTPUT_LENGTH))
{
std::string ciphername = cipher->name(), macname = mac->name();
delete cipher;
delete mac;
throw Internal_Error("Randpool: Invalid algorithm combination " +
cipher->name() + "/" + mac->name());
ciphername + "/" + macname);
}
buffer.create(BLOCK_SIZE);