Add lots of checks for memory allocation failure, error codes to indicate
[openssl.git] / crypto / asn1 / a_digest.c
index 4931e222a05e30c0f47e530f18b05bbe29657049..7182e9fa5d5319e5b42156f5f9ae61ab81d4a8fb 100644 (file)
@@ -65,6 +65,7 @@
 # include <sys/types.h>
 #endif
 
+#include <openssl/err.h>
 #include <openssl/evp.h>
 #include <openssl/buffer.h>
 #include <openssl/x509.h>
@@ -78,7 +79,11 @@ int ASN1_digest(int (*i2d)(), const EVP_MD *type, char *data,
        unsigned char *str,*p;
 
        i=i2d(data,NULL);
-       if ((str=(unsigned char *)OPENSSL_malloc(i)) == NULL) return(0);
+       if ((str=(unsigned char *)OPENSSL_malloc(i)) == NULL)
+               {
+               ASN1err(ASN1_F_ASN1_DIGEST,ERR_R_MALLOC_FAILURE);
+               return(0);
+               }
        p=str;
        i2d(data,&p);