check bn_new return value
authormrpre <mrpre@163.com>
Fri, 28 Aug 2015 08:12:51 +0000 (16:12 +0800)
committerRich Salz <rsalz@openssl.org>
Mon, 31 Aug 2015 20:06:29 +0000 (16:06 -0400)
Slightly modified from the original PR.
Signed-off-by: Rich Salz <rsalz@akamai.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit a7e974c7be90e2c9673e2ce6215a70f734eb8ad4)

crypto/asn1/x_bignum.c

index a5a403c26e10ee155cb7b88e75ff1db974b343f5..eaf046639d6a206339463bae6ea37cee45888f43 100644 (file)
@@ -141,8 +141,9 @@ static int bn_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
                   int utype, char *free_cont, const ASN1_ITEM *it)
 {
     BIGNUM *bn;
-    if (!*pval)
-        bn_new(pval, it);
+
+    if (*pval == NULL && !bn_new(pval, it))
+        return 0;
     bn = (BIGNUM *)*pval;
     if (!BN_bin2bn(cont, len, bn)) {
         bn_free(pval, it);