BN_FLG_FREE is of extremely dubious usefulness, and is only referred to
[openssl.git] / crypto / bn / bn_lib.c
index b499292884ad6b51f9744a4ac1d27880be2f0d5d..3bc67f9de2c267a5a9a4f5f23a38b284cae1bc80 100644 (file)
@@ -131,7 +131,7 @@ int BN_get_params(int which)
 const BIGNUM *BN_value_one(void)
        {
        static BN_ULONG data_one=1L;
-       static BIGNUM const_one={&data_one,1,1,0};
+       static BIGNUM const_one={&data_one,1,1,0,BN_FLG_STATIC_DATA};
 
        return(&const_one);
        }
@@ -278,9 +278,15 @@ void BN_free(BIGNUM *a)
        if (a == NULL) return;
        if ((a->d != NULL) && !(BN_get_flags(a,BN_FLG_STATIC_DATA)))
                OPENSSL_free(a->d);
-       a->flags|=BN_FLG_FREE; /* REMOVE? */
        if (a->flags & BN_FLG_MALLOCED)
                OPENSSL_free(a);
+       else
+               {
+#ifndef OPENSSL_NO_DEPRECATED
+               a->flags|=BN_FLG_FREE;
+#endif
+               a->d = NULL;
+               }
        }
 
 void BN_init(BIGNUM *a)