From bbc738c490bcd691151c28f971e0e153777fb255 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Mon, 14 Jul 2014 17:32:57 +0200 Subject: Static Code Analysis : Add various NULL pointers checks --- src/Common/Crypto.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src/Common/Crypto.c') diff --git a/src/Common/Crypto.c b/src/Common/Crypto.c index 3b87572a..dd30e488 100644 --- a/src/Common/Crypto.c +++ b/src/Common/Crypto.c @@ -321,24 +321,28 @@ Cipher *CipherGet (int id) return NULL; } -char *CipherGetName (int cipherId) +const char *CipherGetName (int cipherId) { - return CipherGet (cipherId) -> Name; + Cipher* pCipher = CipherGet (cipherId); + return pCipher? pCipher -> Name : ""; } int CipherGetBlockSize (int cipherId) { - return CipherGet (cipherId) -> BlockSize; + Cipher* pCipher = CipherGet (cipherId); + return pCipher? pCipher -> BlockSize : 0; } int CipherGetKeySize (int cipherId) { - return CipherGet (cipherId) -> KeySize; + Cipher* pCipher = CipherGet (cipherId); + return pCipher? pCipher -> KeySize : 0; } int CipherGetKeyScheduleSize (int cipherId) { - return CipherGet (cipherId) -> KeyScheduleSize; + Cipher* pCipher = CipherGet (cipherId); + return pCipher? pCipher -> KeyScheduleSize : 0; } #ifndef TC_WINDOWS_BOOT @@ -715,15 +719,17 @@ int HashGetIdByName (char *name) } -char *HashGetName (int hashId) +const char *HashGetName (int hashId) { - return HashGet (hashId) -> Name; + Hash* pHash = HashGet(hashId); + return pHash? pHash -> Name : ""; } BOOL HashIsDeprecated (int hashId) { - return HashGet (hashId) -> Deprecated; + Hash* pHash = HashGet(hashId); + return pHash? pHash -> Deprecated : FALSE; } -- cgit v1.2.3