Fix (minor) problems found by ubsan
[openssl.git] / crypto / evp / digest.c
index 04ab3a09b927f5f4f431a56eacec4a30724134bc..607f0a1a0d0cd0186bbe22e48f9840fc8375f69a 100644 (file)
  */
 
 #include <stdio.h>
-#include "cryptlib.h"
+#include "internal/cryptlib.h"
 #include <openssl/objects.h>
 #include <openssl/evp.h>
 #ifndef OPENSSL_NO_ENGINE
 
 void EVP_MD_CTX_init(EVP_MD_CTX *ctx)
 {
-    memset(ctx, '\0', sizeof(*ctx));
+    memset(ctx, 0, sizeof(*ctx));
 }
 
 EVP_MD_CTX *EVP_MD_CTX_create(void)
 {
     EVP_MD_CTX *ctx = OPENSSL_malloc(sizeof(*ctx));
 
-    if (ctx)
+    if (ctx != NULL)
         EVP_MD_CTX_init(ctx);
 
     return ctx;
@@ -288,7 +288,7 @@ int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in)
             out->md_data = tmp_buf;
         else {
             out->md_data = OPENSSL_malloc(out->digest->ctx_size);
-            if (!out->md_data) {
+            if (out->md_data == NULL) {
                 EVPerr(EVP_F_EVP_MD_CTX_COPY_EX, ERR_R_MALLOC_FAILURE);
                 return 0;
             }
@@ -360,7 +360,7 @@ int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx)
          */
         ENGINE_finish(ctx->engine);
 #endif
-    memset(ctx, '\0', sizeof(*ctx));
+    memset(ctx, 0, sizeof(*ctx));
 
     return 1;
 }