On solaris, the variable name sun clashes, use s_un instead
[openssl.git] / crypto / asn1 / x_bignum.c
index 66ce000827cbe6e2d7306e08ffb8dcb89c01ad0a..c8072e337f946aa5fe0445eafbb83ac33132d449 100644 (file)
@@ -1,4 +1,3 @@
-/* x_bignum.c */
 /*
  * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project
  * 2000.
@@ -111,7 +110,7 @@ ASN1_ITEM_end(CBIGNUM)
 static int bn_new(ASN1_VALUE **pval, const ASN1_ITEM *it)
 {
     *pval = (ASN1_VALUE *)BN_new();
-    if (*pval)
+    if (*pval != NULL)
         return 1;
     else
         return 0;
@@ -120,7 +119,7 @@ static int bn_new(ASN1_VALUE **pval, const ASN1_ITEM *it)
 static int bn_secure_new(ASN1_VALUE **pval, const ASN1_ITEM *it)
 {
     *pval = (ASN1_VALUE *)BN_secure_new();
-    if (*pval)
+    if (*pval != NULL)
         return 1;
     else
         return 0;
@@ -163,8 +162,8 @@ static int bn_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
 {
     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);