Fix error handling at openssl_strerror_r
[oweals/openssl.git] / crypto / poly1305 / poly1305_pmeth.c
index 7bc6add6811bc491990f3d0e3983ec18026c1ff7..3bc24c98cd614705fadb005a57f8f050bd68f6e1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2007-2017 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2007-2018 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the OpenSSL license (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -12,6 +12,7 @@
 #include <openssl/x509.h>
 #include <openssl/x509v3.h>
 #include <openssl/evp.h>
+#include <openssl/err.h>
 #include "internal/poly1305.h"
 #include "poly1305_local.h"
 #include "internal/evp_int.h"
@@ -27,9 +28,10 @@ static int pkey_poly1305_init(EVP_PKEY_CTX *ctx)
 {
     POLY1305_PKEY_CTX *pctx;
 
-    pctx = OPENSSL_zalloc(sizeof(*pctx));
-    if (pctx == NULL)
+    if ((pctx = OPENSSL_zalloc(sizeof(*pctx))) == NULL) {
+        CRYPTOerr(CRYPTO_F_PKEY_POLY1305_INIT, ERR_R_MALLOC_FAILURE);
         return 0;
+    }
     pctx->ktmp.type = V_ASN1_OCTET_STRING;
 
     EVP_PKEY_CTX_set_data(ctx, pctx);