]> git.ipfire.org Git - thirdparty/openssl.git/blobdiff - crypto/hmac/hm_ameth.c
Continue standardising malloc style for libcrypto
[thirdparty/openssl.git] / crypto / hmac / hm_ameth.c
index 1b0f3b97c56b338f4d2392f9eeede3ce13c0d261..df6bf0b3ef64d7ebf240db0b15cde90348f4f58e 100644 (file)
@@ -57,7 +57,7 @@
  */
 
 #include <stdio.h>
-#include "cryptlib.h"
+#include "internal/cryptlib.h"
 #include <openssl/evp.h>
 #include "internal/asn1_int.h"
 
@@ -107,10 +107,15 @@ static int old_hmac_decode(EVP_PKEY *pkey,
 {
     ASN1_OCTET_STRING *os;
     os = ASN1_OCTET_STRING_new();
-    if (!os || !ASN1_OCTET_STRING_set(os, *pder, derlen))
-        return 0;
-    EVP_PKEY_assign(pkey, EVP_PKEY_HMAC, os);
+    if (os == NULL || !ASN1_OCTET_STRING_set(os, *pder, derlen))
+        goto err;
+    if (!EVP_PKEY_assign(pkey, EVP_PKEY_HMAC, os))
+        goto err;
     return 1;
+
+ err:
+    ASN1_OCTET_STRING_free(os);
+    return 0;
 }
 
 static int old_hmac_encode(const EVP_PKEY *pkey, unsigned char **pder)