Fix for crashing INTEGERs, ENUMERATEDs and OBJECT IDENTIFIERs.
[openssl.git] / crypto / asn1 / a_object.c
index b94b418..ab69b95 100644 (file)
@@ -223,7 +223,7 @@ ASN1_OBJECT *d2i_ASN1_OBJECT(ASN1_OBJECT **a, unsigned char **pp,
        if ((ret->data == NULL) || (ret->length < len))
                {
                if (ret->data != NULL) Free((char *)ret->data);
-               ret->data=(unsigned char *)Malloc((int)len);
+               ret->data=(unsigned char *)Malloc(len ? (int)len : 1);
                ret->flags|=ASN1_OBJECT_FLAG_DYNAMIC_DATA;
                if (ret->data == NULL)
                        { i=ERR_R_MALLOC_FAILURE; goto err; }