Call of memcmp with null pointers in obj_cmp()
[oweals/openssl.git] / test / dhtest.c
index 6c063daf3d66fd67405f89b316a248d87f7ea1d1..7e46166eeba9c11326fc16115aad3fcbadce8b0e 100644 (file)
@@ -165,7 +165,7 @@ int main(int argc, char *argv[])
     BIO_puts(out, "\n");
 
     alen = DH_size(a);
-    abuf = (unsigned char *)OPENSSL_malloc(alen);
+    abuf = OPENSSL_malloc(alen);
     aout = DH_compute_key(abuf, b->pub_key, a);
 
     BIO_puts(out, "key1 =");
@@ -176,7 +176,7 @@ int main(int argc, char *argv[])
     BIO_puts(out, "\n");
 
     blen = DH_size(b);
-    bbuf = (unsigned char *)OPENSSL_malloc(blen);
+    bbuf = OPENSSL_malloc(blen);
     bout = DH_compute_key(bbuf, a->pub_key, b);
 
     BIO_puts(out, "key2 =");
@@ -195,14 +195,11 @@ int main(int argc, char *argv[])
  err:
     ERR_print_errors_fp(stderr);
 
-    if (abuf != NULL)
-        OPENSSL_free(abuf);
-    if (bbuf != NULL)
-        OPENSSL_free(bbuf);
+    OPENSSL_free(abuf);
+    OPENSSL_free(bbuf);
     DH_free(b);
     DH_free(a);
-    if (_cb)
-        BN_GENCB_free(_cb);
+    BN_GENCB_free(_cb);
     BIO_free(out);
 # ifdef OPENSSL_SYS_NETWARE
     if (ret)
@@ -488,7 +485,7 @@ static const rfc5114_td rfctd[] = {
 static int run_rfc5114_tests(void)
 {
     int i;
-    for (i = 0; i < (int)(sizeof(rfctd) / sizeof(rfc5114_td)); i++) {
+    for (i = 0; i < (int)OSSL_NELEM(rfctd); i++) {
         DH *dhA, *dhB;
         unsigned char *Z1 = NULL, *Z2 = NULL;
         const rfc5114_td *td = rfctd + i;