Fix Coverity issues 03/255503/1 accepted/tizen/unified/20210328.230653 submit/tizen/20210324.050340
authorJihoon Jung <jh8801.jung@samsung.com>
Fri, 19 Mar 2021 03:12:55 +0000 (12:12 +0900)
committerJihoon Jung <jh8801.jung@samsung.com>
Fri, 19 Mar 2021 03:12:55 +0000 (12:12 +0900)
CID : 1222319, 1222330 : Dereference null return

Change-Id: I649aa4a72932664805bfea7acda692725abba088
Signed-off-by: Jihoon Jung <jh8801.jung@samsung.com>
src/commonlib/net_nfc_util_openssl.c

index 75aa972..45bec40 100644 (file)
@@ -393,6 +393,10 @@ int net_nfc_util_openssl_sign_buffer(uint32_t type, uint8_t * buffer, uint32_t l
 #else // OpenSSL 1.1.1
        EVP_MD_CTX *ctx;
        ctx = EVP_MD_CTX_new();
+       if (ctx == NULL) {
+               DEBUG_ERR_MSG("ctx is NULL");
+               return -1;
+       }
 #endif
        EVP_PKEY_CTX *pctx = NULL;
 
@@ -497,6 +501,10 @@ int net_nfc_util_openssl_verify_signature(uint32_t type, uint8_t * buffer, uint3
 #else // OpenSSL 1.1.1
        EVP_MD_CTX *ctx;
        ctx = EVP_MD_CTX_new();
+       if (ctx == NULL) {
+               DEBUG_ERR_MSG("ctx is NULL");
+               return -1;
+       }
 #endif
        EVP_PKEY_CTX *pctx = NULL;
 
@@ -813,6 +821,10 @@ bool net_nfc_util_openssl_digest(const char *algorithm, const uint8_t * buffer,
 #else // OpenSSL 1.1.1
                        EVP_MD_CTX *mdCtx;
                        mdCtx = EVP_MD_CTX_new();
+                       if (mdCtx == NULL) {
+                               DEBUG_ERR_MSG("mdCtx is NULL");
+                               return false;
+                       }
 #endif
                        unsigned int resultLen = 0;