Coverity: fix two minor NPD issues.
authorFdaSilvaYY <fdasilvayy@gmail.com>
Sat, 6 Apr 2019 09:16:59 +0000 (19:16 +1000)
committerTomas Mraz <tmraz@fedoraproject.org>
Fri, 20 Mar 2020 12:31:21 +0000 (13:31 +0100)
Found by Coverity.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8274)

(cherry picked from commit 23dc8feba817560485da00d690d7b7b9e5b15682)

crypto/conf/conf_lib.c
crypto/ex_data.c

index 0b7dd26d63b0a0de3f9dbc826409fa96641ea612..c278d870916b18560bfaece54737a1676d8093d7 100644 (file)
@@ -356,8 +356,10 @@ OPENSSL_INIT_SETTINGS *OPENSSL_INIT_new(void)
 {
     OPENSSL_INIT_SETTINGS *ret = malloc(sizeof(*ret));
 
-    if (ret != NULL)
-        memset(ret, 0, sizeof(*ret));
+    if (ret == NULL)
+        return NULL;
+
+    memset(ret, 0, sizeof(*ret));
     ret->flags = DEFAULT_CONF_MFLAGS;
 
     return ret;
index 22f3b70edf14e3666a8108170de7c3f9dcc8373d..3d13901fc99f1abd4d21f10c1c1c1fe7bc5c8db5 100644 (file)
@@ -235,7 +235,7 @@ int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad)
         return 0;
     }
     for (i = 0; i < mx; i++) {
-        if (storage[i] && storage[i]->new_func) {
+        if (storage[i] != NULL && storage[i]->new_func != NULL) {
             ptr = CRYPTO_get_ex_data(ad, i);
             storage[i]->new_func(obj, ptr, ad, i,
                                  storage[i]->argl, storage[i]->argp);
@@ -299,7 +299,7 @@ int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
 
     for (i = 0; i < mx; i++) {
         ptr = CRYPTO_get_ex_data(from, i);
-        if (storage[i] && storage[i]->dup_func)
+        if (storage[i] != NULL && storage[i]->dup_func != NULL)
             if (!storage[i]->dup_func(to, from, &ptr, i,
                                       storage[i]->argl, storage[i]->argp))
                 goto err;