test/bntest.c:1733: error: MEMORY_LEAK
  memory dynamically allocated by call to `BN_new()` at line 1651, column 9 is not reachable after line 1733, column 5.
Showing all 116 steps of the trace


test/bntest.c:1643:1: start of procedure test_kron()
1641.   }
1642.   
1643. > int test_kron(BIO *bp, BN_CTX *ctx)
1644.   {
1645.       BN_GENCB cb;

test/bntest.c:1649:5: 
1647.       int i;
1648.       int legendre, kronecker;
1649. >     int ret = 0;
1650.   
1651.       a = BN_new();

test/bntest.c:1651:5: 
1649.       int ret = 0;
1650.   
1651. >     a = BN_new();
1652.       b = BN_new();
1653.       r = BN_new();

crypto/bn/bn_lib.c:277:1: start of procedure BN_new()
  275.   }
  276.   
  277. > BIGNUM *BN_new(void)
  278.   {
  279.       BIGNUM *ret;

crypto/bn/bn_lib.c:281:9: 
  279.       BIGNUM *ret;
  280.   
  281. >     if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) {
  282.           BNerr(BN_F_BN_NEW, ERR_R_MALLOC_FAILURE);
  283.           return (NULL);

crypto/mem.c:157:1: start of procedure CRYPTO_zalloc()
    155.   }
    156.   
    157. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    158.   {
    159.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:159:5: 
    157.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    158.   {
    159. >     void *ret = CRYPTO_malloc(num, file, line);
    160.   
    161.       if (ret != NULL)

crypto/mem.c:120:1: start of procedure CRYPTO_malloc()
      118.   }
      119.   
      120. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      121.   {
      122.       void *ret = NULL;

crypto/mem.c:122:5: 
      120.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      121.   {
      122. >     void *ret = NULL;
      123.   
      124.       if (num <= 0)

crypto/mem.c:124:9: Taking false branch
      122.       void *ret = NULL;
      123.   
      124.       if (num <= 0)
                     ^
      125.           return NULL;
      126.   

crypto/mem.c:127:5: 
      125.           return NULL;
      126.   
      127. >     allow_customize = 0;
      128.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
      129.       if (call_malloc_debug) {

crypto/mem.c:137:5: 
      135.       }
      136.   #else
      137. >     (void)file;
      138.       (void)line;
      139.       ret = malloc(num);

crypto/mem.c:138:5: 
      136.   #else
      137.       (void)file;
      138. >     (void)line;
      139.       ret = malloc(num);
      140.   #endif

crypto/mem.c:139:5: 
      137.       (void)file;
      138.       (void)line;
      139. >     ret = malloc(num);
      140.   #endif
      141.   

crypto/mem.c:154:5: 
      152.   #endif
      153.   
      154. >     return ret;
      155.   }
      156.   

crypto/mem.c:155:1: return from a call to CRYPTO_malloc
      153.   
      154.       return ret;
      155. > }
      156.   
      157.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:161:9: Taking true branch
    159.       void *ret = CRYPTO_malloc(num, file, line);
    160.   
    161.       if (ret != NULL)
                   ^
    162.           memset(ret, 0, num);
    163.       return ret;

crypto/mem.c:162:9: 
    160.   
    161.       if (ret != NULL)
    162. >         memset(ret, 0, num);
    163.       return ret;
    164.   }

crypto/mem.c:163:5: 
    161.       if (ret != NULL)
    162.           memset(ret, 0, num);
    163. >     return ret;
    164.   }
    165.   

crypto/mem.c:164:1: return from a call to CRYPTO_zalloc
    162.           memset(ret, 0, num);
    163.       return ret;
    164. > }
    165.   
    166.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/bn/bn_lib.c:281:9: Taking false branch
  279.       BIGNUM *ret;
  280.   
  281.       if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) {
                 ^
  282.           BNerr(BN_F_BN_NEW, ERR_R_MALLOC_FAILURE);
  283.           return (NULL);

crypto/bn/bn_lib.c:285:5: 
  283.           return (NULL);
  284.       }
  285. >     ret->flags = BN_FLG_MALLOCED;
  286.       bn_check_top(ret);
  287.       return (ret);

crypto/bn/bn_lib.c:287:5: 
  285.       ret->flags = BN_FLG_MALLOCED;
  286.       bn_check_top(ret);
  287. >     return (ret);
  288.   }
  289.   

crypto/bn/bn_lib.c:288:1: return from a call to BN_new
  286.       bn_check_top(ret);
  287.       return (ret);
  288. > }
  289.   
  290.    BIGNUM *BN_secure_new(void)

test/bntest.c:1652:5: 
1650.   
1651.       a = BN_new();
1652. >     b = BN_new();
1653.       r = BN_new();
1654.       t = BN_new();

crypto/bn/bn_lib.c:277:1: start of procedure BN_new()
  275.   }
  276.   
  277. > BIGNUM *BN_new(void)
  278.   {
  279.       BIGNUM *ret;

crypto/bn/bn_lib.c:281:9: 
  279.       BIGNUM *ret;
  280.   
  281. >     if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) {
  282.           BNerr(BN_F_BN_NEW, ERR_R_MALLOC_FAILURE);
  283.           return (NULL);

crypto/mem.c:157:1: start of procedure CRYPTO_zalloc()
    155.   }
    156.   
    157. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    158.   {
    159.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:159:5: 
    157.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    158.   {
    159. >     void *ret = CRYPTO_malloc(num, file, line);
    160.   
    161.       if (ret != NULL)

crypto/mem.c:120:1: start of procedure CRYPTO_malloc()
      118.   }
      119.   
      120. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      121.   {
      122.       void *ret = NULL;

crypto/mem.c:122:5: 
      120.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      121.   {
      122. >     void *ret = NULL;
      123.   
      124.       if (num <= 0)

crypto/mem.c:124:9: Taking false branch
      122.       void *ret = NULL;
      123.   
      124.       if (num <= 0)
                     ^
      125.           return NULL;
      126.   

crypto/mem.c:127:5: 
      125.           return NULL;
      126.   
      127. >     allow_customize = 0;
      128.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
      129.       if (call_malloc_debug) {

crypto/mem.c:137:5: 
      135.       }
      136.   #else
      137. >     (void)file;
      138.       (void)line;
      139.       ret = malloc(num);

crypto/mem.c:138:5: 
      136.   #else
      137.       (void)file;
      138. >     (void)line;
      139.       ret = malloc(num);
      140.   #endif

crypto/mem.c:139:5: 
      137.       (void)file;
      138.       (void)line;
      139. >     ret = malloc(num);
      140.   #endif
      141.   

crypto/mem.c:154:5: 
      152.   #endif
      153.   
      154. >     return ret;
      155.   }
      156.   

crypto/mem.c:155:1: return from a call to CRYPTO_malloc
      153.   
      154.       return ret;
      155. > }
      156.   
      157.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:161:9: Taking true branch
    159.       void *ret = CRYPTO_malloc(num, file, line);
    160.   
    161.       if (ret != NULL)
                   ^
    162.           memset(ret, 0, num);
    163.       return ret;

crypto/mem.c:162:9: 
    160.   
    161.       if (ret != NULL)
    162. >         memset(ret, 0, num);
    163.       return ret;
    164.   }

crypto/mem.c:163:5: 
    161.       if (ret != NULL)
    162.           memset(ret, 0, num);
    163. >     return ret;
    164.   }
    165.   

crypto/mem.c:164:1: return from a call to CRYPTO_zalloc
    162.           memset(ret, 0, num);
    163.       return ret;
    164. > }
    165.   
    166.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/bn/bn_lib.c:281:9: Taking false branch
  279.       BIGNUM *ret;
  280.   
  281.       if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) {
                 ^
  282.           BNerr(BN_F_BN_NEW, ERR_R_MALLOC_FAILURE);
  283.           return (NULL);

crypto/bn/bn_lib.c:285:5: 
  283.           return (NULL);
  284.       }
  285. >     ret->flags = BN_FLG_MALLOCED;
  286.       bn_check_top(ret);
  287.       return (ret);

crypto/bn/bn_lib.c:287:5: 
  285.       ret->flags = BN_FLG_MALLOCED;
  286.       bn_check_top(ret);
  287. >     return (ret);
  288.   }
  289.   

crypto/bn/bn_lib.c:288:1: return from a call to BN_new
  286.       bn_check_top(ret);
  287.       return (ret);
  288. > }
  289.   
  290.    BIGNUM *BN_secure_new(void)

test/bntest.c:1653:5: 
1651.       a = BN_new();
1652.       b = BN_new();
1653. >     r = BN_new();
1654.       t = BN_new();
1655.       if (a == NULL || b == NULL || r == NULL || t == NULL)

crypto/bn/bn_lib.c:277:1: start of procedure BN_new()
  275.   }
  276.   
  277. > BIGNUM *BN_new(void)
  278.   {
  279.       BIGNUM *ret;

crypto/bn/bn_lib.c:281:9: 
  279.       BIGNUM *ret;
  280.   
  281. >     if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) {
  282.           BNerr(BN_F_BN_NEW, ERR_R_MALLOC_FAILURE);
  283.           return (NULL);

crypto/mem.c:157:1: start of procedure CRYPTO_zalloc()
    155.   }
    156.   
    157. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    158.   {
    159.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:159:5: 
    157.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    158.   {
    159. >     void *ret = CRYPTO_malloc(num, file, line);
    160.   
    161.       if (ret != NULL)

crypto/mem.c:120:1: start of procedure CRYPTO_malloc()
      118.   }
      119.   
      120. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      121.   {
      122.       void *ret = NULL;

crypto/mem.c:122:5: 
      120.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      121.   {
      122. >     void *ret = NULL;
      123.   
      124.       if (num <= 0)

crypto/mem.c:124:9: Taking false branch
      122.       void *ret = NULL;
      123.   
      124.       if (num <= 0)
                     ^
      125.           return NULL;
      126.   

crypto/mem.c:127:5: 
      125.           return NULL;
      126.   
      127. >     allow_customize = 0;
      128.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
      129.       if (call_malloc_debug) {

crypto/mem.c:137:5: 
      135.       }
      136.   #else
      137. >     (void)file;
      138.       (void)line;
      139.       ret = malloc(num);

crypto/mem.c:138:5: 
      136.   #else
      137.       (void)file;
      138. >     (void)line;
      139.       ret = malloc(num);
      140.   #endif

crypto/mem.c:139:5: 
      137.       (void)file;
      138.       (void)line;
      139. >     ret = malloc(num);
      140.   #endif
      141.   

crypto/mem.c:154:5: 
      152.   #endif
      153.   
      154. >     return ret;
      155.   }
      156.   

crypto/mem.c:155:1: return from a call to CRYPTO_malloc
      153.   
      154.       return ret;
      155. > }
      156.   
      157.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:161:9: Taking true branch
    159.       void *ret = CRYPTO_malloc(num, file, line);
    160.   
    161.       if (ret != NULL)
                   ^
    162.           memset(ret, 0, num);
    163.       return ret;

crypto/mem.c:162:9: 
    160.   
    161.       if (ret != NULL)
    162. >         memset(ret, 0, num);
    163.       return ret;
    164.   }

crypto/mem.c:163:5: 
    161.       if (ret != NULL)
    162.           memset(ret, 0, num);
    163. >     return ret;
    164.   }
    165.   

crypto/mem.c:164:1: return from a call to CRYPTO_zalloc
    162.           memset(ret, 0, num);
    163.       return ret;
    164. > }
    165.   
    166.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/bn/bn_lib.c:281:9: Taking false branch
  279.       BIGNUM *ret;
  280.   
  281.       if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) {
                 ^
  282.           BNerr(BN_F_BN_NEW, ERR_R_MALLOC_FAILURE);
  283.           return (NULL);

crypto/bn/bn_lib.c:285:5: 
  283.           return (NULL);
  284.       }
  285. >     ret->flags = BN_FLG_MALLOCED;
  286.       bn_check_top(ret);
  287.       return (ret);

crypto/bn/bn_lib.c:287:5: 
  285.       ret->flags = BN_FLG_MALLOCED;
  286.       bn_check_top(ret);
  287. >     return (ret);
  288.   }
  289.   

crypto/bn/bn_lib.c:288:1: return from a call to BN_new
  286.       bn_check_top(ret);
  287.       return (ret);
  288. > }
  289.   
  290.    BIGNUM *BN_secure_new(void)

test/bntest.c:1654:5: 
1652.       b = BN_new();
1653.       r = BN_new();
1654. >     t = BN_new();
1655.       if (a == NULL || b == NULL || r == NULL || t == NULL)
1656.           goto err;

crypto/bn/bn_lib.c:277:1: start of procedure BN_new()
  275.   }
  276.   
  277. > BIGNUM *BN_new(void)
  278.   {
  279.       BIGNUM *ret;

crypto/bn/bn_lib.c:281:9: 
  279.       BIGNUM *ret;
  280.   
  281. >     if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) {
  282.           BNerr(BN_F_BN_NEW, ERR_R_MALLOC_FAILURE);
  283.           return (NULL);

crypto/mem.c:157:1: start of procedure CRYPTO_zalloc()
    155.   }
    156.   
    157. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    158.   {
    159.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:159:5: 
    157.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    158.   {
    159. >     void *ret = CRYPTO_malloc(num, file, line);
    160.   
    161.       if (ret != NULL)

crypto/mem.c:120:1: start of procedure CRYPTO_malloc()
      118.   }
      119.   
      120. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      121.   {
      122.       void *ret = NULL;

crypto/mem.c:122:5: 
      120.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      121.   {
      122. >     void *ret = NULL;
      123.   
      124.       if (num <= 0)

crypto/mem.c:124:9: Taking false branch
      122.       void *ret = NULL;
      123.   
      124.       if (num <= 0)
                     ^
      125.           return NULL;
      126.   

crypto/mem.c:127:5: 
      125.           return NULL;
      126.   
      127. >     allow_customize = 0;
      128.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
      129.       if (call_malloc_debug) {

crypto/mem.c:137:5: 
      135.       }
      136.   #else
      137. >     (void)file;
      138.       (void)line;
      139.       ret = malloc(num);

crypto/mem.c:138:5: 
      136.   #else
      137.       (void)file;
      138. >     (void)line;
      139.       ret = malloc(num);
      140.   #endif

crypto/mem.c:139:5: 
      137.       (void)file;
      138.       (void)line;
      139. >     ret = malloc(num);
      140.   #endif
      141.   

crypto/mem.c:154:5: 
      152.   #endif
      153.   
      154. >     return ret;
      155.   }
      156.   

crypto/mem.c:155:1: return from a call to CRYPTO_malloc
      153.   
      154.       return ret;
      155. > }
      156.   
      157.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:161:9: Taking true branch
    159.       void *ret = CRYPTO_malloc(num, file, line);
    160.   
    161.       if (ret != NULL)
                   ^
    162.           memset(ret, 0, num);
    163.       return ret;

crypto/mem.c:162:9: 
    160.   
    161.       if (ret != NULL)
    162. >         memset(ret, 0, num);
    163.       return ret;
    164.   }

crypto/mem.c:163:5: 
    161.       if (ret != NULL)
    162.           memset(ret, 0, num);
    163. >     return ret;
    164.   }
    165.   

crypto/mem.c:164:1: return from a call to CRYPTO_zalloc
    162.           memset(ret, 0, num);
    163.       return ret;
    164. > }
    165.   
    166.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/bn/bn_lib.c:281:9: Taking false branch
  279.       BIGNUM *ret;
  280.   
  281.       if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) {
                 ^
  282.           BNerr(BN_F_BN_NEW, ERR_R_MALLOC_FAILURE);
  283.           return (NULL);

crypto/bn/bn_lib.c:285:5: 
  283.           return (NULL);
  284.       }
  285. >     ret->flags = BN_FLG_MALLOCED;
  286.       bn_check_top(ret);
  287.       return (ret);

crypto/bn/bn_lib.c:287:5: 
  285.       ret->flags = BN_FLG_MALLOCED;
  286.       bn_check_top(ret);
  287. >     return (ret);
  288.   }
  289.   

crypto/bn/bn_lib.c:288:1: return from a call to BN_new
  286.       bn_check_top(ret);
  287.       return (ret);
  288. > }
  289.   
  290.    BIGNUM *BN_secure_new(void)

test/bntest.c:1655:9: Taking false branch
1653.       r = BN_new();
1654.       t = BN_new();
1655.       if (a == NULL || b == NULL || r == NULL || t == NULL)
                ^
1656.           goto err;
1657.   

test/bntest.c:1655:22: Taking false branch
1653.       r = BN_new();
1654.       t = BN_new();
1655.       if (a == NULL || b == NULL || r == NULL || t == NULL)
                             ^
1656.           goto err;
1657.   

test/bntest.c:1655:35: Taking false branch
1653.       r = BN_new();
1654.       t = BN_new();
1655.       if (a == NULL || b == NULL || r == NULL || t == NULL)
                                          ^
1656.           goto err;
1657.   

test/bntest.c:1655:48: Taking false branch
1653.       r = BN_new();
1654.       t = BN_new();
1655.       if (a == NULL || b == NULL || r == NULL || t == NULL)
                                                       ^
1656.           goto err;
1657.   

test/bntest.c:1658:5: 
1656.           goto err;
1657.   
1658. >     BN_GENCB_set(&cb, genprime_cb, NULL);
1659.   
1660.       /*

crypto/bn/bn_lib.c:981:1: start of procedure BN_GENCB_set()
  979.   
  980.   /* Populate a BN_GENCB structure with a "new"-style callback */
  981. > void BN_GENCB_set(BN_GENCB *gencb, int (*callback) (int, int, BN_GENCB *),
  982.                     void *cb_arg)
  983.   {

crypto/bn/bn_lib.c:984:5: 
  982.                     void *cb_arg)
  983.   {
  984. >     BN_GENCB *tmp_gencb = gencb;
  985.       tmp_gencb->ver = 2;
  986.       tmp_gencb->arg = cb_arg;

crypto/bn/bn_lib.c:985:5: 
  983.   {
  984.       BN_GENCB *tmp_gencb = gencb;
  985. >     tmp_gencb->ver = 2;
  986.       tmp_gencb->arg = cb_arg;
  987.       tmp_gencb->cb.cb_2 = callback;

crypto/bn/bn_lib.c:986:5: 
  984.       BN_GENCB *tmp_gencb = gencb;
  985.       tmp_gencb->ver = 2;
  986. >     tmp_gencb->arg = cb_arg;
  987.       tmp_gencb->cb.cb_2 = callback;
  988.   }

crypto/bn/bn_lib.c:987:5: 
  985.       tmp_gencb->ver = 2;
  986.       tmp_gencb->arg = cb_arg;
  987. >     tmp_gencb->cb.cb_2 = callback;
  988.   }
  989.   

crypto/bn/bn_lib.c:988:1: return from a call to BN_GENCB_set
  986.       tmp_gencb->arg = cb_arg;
  987.       tmp_gencb->cb.cb_2 = callback;
  988. > }
  989.   
  990.   void *BN_GENCB_get_arg(BN_GENCB *cb)

test/bntest.c:1670:10: Taking true branch
1668.        */
1669.   
1670.       if (!BN_generate_prime_ex(b, 512, 0, NULL, NULL, &cb))
                 ^
1671.           goto err;
1672.       b->neg = rand_neg();

test/bntest.c:1732:2: 
1730.       fflush(stderr);
1731.       ret = 1;
1732. >  err:
1733.       BN_free(a);
1734.       BN_free(b);

test/bntest.c:1733:5: 
1731.       ret = 1;
1732.    err:
1733. >     BN_free(a);
1734.       BN_free(b);
1735.       BN_free(r);

crypto/bn/bn_lib.c:252:1: start of procedure BN_free()
  250.   }
  251.   
  252. > void BN_free(BIGNUM *a)
  253.   {
  254.       if (a == NULL)

crypto/bn/bn_lib.c:254:9: Taking false branch
  252.   void BN_free(BIGNUM *a)
  253.   {
  254.       if (a == NULL)
                 ^
  255.           return;
  256.       bn_check_top(a);

crypto/bn/bn_lib.c:257:10: 
  255.           return;
  256.       bn_check_top(a);
  257. >     if (!BN_get_flags(a, BN_FLG_STATIC_DATA))
  258.           bn_free_d(a);
  259.       if (a->flags & BN_FLG_MALLOCED)

crypto/bn/bn_lib.c:965:1: start of procedure BN_get_flags()
    963.   }
    964.   
    965. > int BN_get_flags(const BIGNUM *b, int n)
    966.   {
    967.       return b->flags & n;

crypto/bn/bn_lib.c:967:5: 
    965.   int BN_get_flags(const BIGNUM *b, int n)
    966.   {
    967. >     return b->flags & n;
    968.   }
    969.   

crypto/bn/bn_lib.c:968:1: return from a call to BN_get_flags
    966.   {
    967.       return b->flags & n;
    968. > }
    969.   
    970.   /* Populate a BN_GENCB structure with an "old"-style callback */

crypto/bn/bn_lib.c:257:10: Taking false branch
  255.           return;
  256.       bn_check_top(a);
  257.       if (!BN_get_flags(a, BN_FLG_STATIC_DATA))
                  ^
  258.           bn_free_d(a);
  259.       if (a->flags & BN_FLG_MALLOCED)

crypto/bn/bn_lib.c:259:9: Taking false branch
  257.       if (!BN_get_flags(a, BN_FLG_STATIC_DATA))
  258.           bn_free_d(a);
  259.       if (a->flags & BN_FLG_MALLOCED)
                 ^
  260.           OPENSSL_free(a);
  261.       else {

crypto/bn/bn_lib.c:263:9: 
  261.       else {
  262.   #if OPENSSL_API_COMPAT < 0x00908000L
  263. >         a->flags |= BN_FLG_FREE;
  264.   #endif
  265.           a->d = NULL;

crypto/bn/bn_lib.c:265:9: 
  263.           a->flags |= BN_FLG_FREE;
  264.   #endif
  265. >         a->d = NULL;
  266.       }
  267.   }

crypto/bn/bn_lib.c:259:5: 
  257.       if (!BN_get_flags(a, BN_FLG_STATIC_DATA))
  258.           bn_free_d(a);
  259. >     if (a->flags & BN_FLG_MALLOCED)
  260.           OPENSSL_free(a);
  261.       else {

crypto/bn/bn_lib.c:267:1: return from a call to BN_free
  265.           a->d = NULL;
  266.       }
  267. > }
  268.   
  269.   void bn_init(BIGNUM *a)

int test_kron(BIO *bp, BN_CTX *ctx)
{
    BN_GENCB cb;
    BIGNUM *a, *b, *r, *t;
    int i;
    int legendre, kronecker;
    int ret = 0;
    a = BN_new();
    b = BN_new();
    r = BN_new();
    t = BN_new();
    if (a == NULL || b == NULL || r == NULL || t == NULL)
        goto err;
    BN_GENCB_set(&cb, genprime_cb, NULL);
    if (!BN_generate_prime_ex(b, 512, 0, NULL, NULL, &cb))
        goto err;
    b->neg = rand_neg();
    putc('\n', stderr);
    for (i = 0; i < num0; i++) {
        if (!BN_bntest_rand(a, 512, 0, 0))
            goto err;
        a->neg = rand_neg();
        if (!BN_copy(t, b))
            goto err;
        t->neg = 0;
        if (!BN_sub_word(t, 1))
            goto err;
        if (!BN_rshift1(t, t))
            goto err;
        b->neg = 0;
        if (!BN_mod_exp_recp(r, a, t, b, ctx))
            goto err;
        b->neg = 1;
        if (BN_is_word(r, 1))
            legendre = 1;
        else if (BN_is_zero(r))
            legendre = 0;
        else {
            if (!BN_add_word(r, 1))
                goto err;
            if (0 != BN_ucmp(r, b)) {
                fprintf(stderr, "Legendre symbol computation failed\n");
                goto err;
            }
            legendre = -1;
        }
        kronecker = BN_kronecker(a, b, ctx);
        if (kronecker < -1)
            goto err;
        if (a->neg && b->neg)
            kronecker = -kronecker;
        if (legendre != kronecker) {
            fprintf(stderr, "legendre != kronecker; a = ");
            BN_print_fp(stderr, a);
            fprintf(stderr, ", b = ");
            BN_print_fp(stderr, b);
            fprintf(stderr, "\n");
            goto err;
        }
        putc('.', stderr);
        fflush(stderr);
    }
    putc('\n', stderr);
    fflush(stderr);
    ret = 1;
 err:
    BN_free(a);
    BN_free(b);
    BN_free(r);
    BN_free(t);
    return ret;
}
['int test_kron(BIO *bp, BN_CTX *ctx)\n{\n    BN_GENCB cb;\n    BIGNUM *a, *b, *r, *t;\n    int i;\n    int legendre, kronecker;\n    int ret = 0;\n    a = BN_new();\n    b = BN_new();\n    r = BN_new();\n    t = BN_new();\n    if (a == NULL || b == NULL || r == NULL || t == NULL)\n        goto err;\n    BN_GENCB_set(&cb, genprime_cb, NULL);\n    if (!BN_generate_prime_ex(b, 512, 0, NULL, NULL, &cb))\n        goto err;\n    b->neg = rand_neg();\n    putc(\'\\n\', stderr);\n    for (i = 0; i < num0; i++) {\n        if (!BN_bntest_rand(a, 512, 0, 0))\n            goto err;\n        a->neg = rand_neg();\n        if (!BN_copy(t, b))\n            goto err;\n        t->neg = 0;\n        if (!BN_sub_word(t, 1))\n            goto err;\n        if (!BN_rshift1(t, t))\n            goto err;\n        b->neg = 0;\n        if (!BN_mod_exp_recp(r, a, t, b, ctx))\n            goto err;\n        b->neg = 1;\n        if (BN_is_word(r, 1))\n            legendre = 1;\n        else if (BN_is_zero(r))\n            legendre = 0;\n        else {\n            if (!BN_add_word(r, 1))\n                goto err;\n            if (0 != BN_ucmp(r, b)) {\n                fprintf(stderr, "Legendre symbol computation failed\\n");\n                goto err;\n            }\n            legendre = -1;\n        }\n        kronecker = BN_kronecker(a, b, ctx);\n        if (kronecker < -1)\n            goto err;\n        if (a->neg && b->neg)\n            kronecker = -kronecker;\n        if (legendre != kronecker) {\n            fprintf(stderr, "legendre != kronecker; a = ");\n            BN_print_fp(stderr, a);\n            fprintf(stderr, ", b = ");\n            BN_print_fp(stderr, b);\n            fprintf(stderr, "\\n");\n            goto err;\n        }\n        putc(\'.\', stderr);\n        fflush(stderr);\n    }\n    putc(\'\\n\', stderr);\n    fflush(stderr);\n    ret = 1;\n err:\n    BN_free(a);\n    BN_free(b);\n    BN_free(r);\n    BN_free(t);\n    return ret;\n}', 'BIGNUM *BN_new(void)\n{\n    BIGNUM *ret;\n    if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) {\n        BNerr(BN_F_BN_NEW, ERR_R_MALLOC_FAILURE);\n        return (NULL);\n    }\n    ret->flags = BN_FLG_MALLOCED;\n    bn_check_top(ret);\n    return (ret);\n}', 'void *CRYPTO_zalloc(size_t num, const char *file, int line)\n{\n    void *ret = CRYPTO_malloc(num, file, line);\n    if (ret != NULL)\n        memset(ret, 0, num);\n    return ret;\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\n    if (num <= 0)\n        return NULL;\n    allow_customize = 0;\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_malloc(NULL, num, 0, file, line);\n        ret = malloc(num);\n        CRYPTO_mem_debug_malloc(ret, num, 1, file, line);\n    } else {\n        ret = malloc(num);\n    }\n#else\n    (void)file;\n    (void)line;\n    ret = malloc(num);\n#endif\n#ifndef OPENSSL_CPUID_OBJ\n    if (ret && (num > 2048)) {\n        extern unsigned char cleanse_ctr;\n        ((unsigned char *)ret)[0] = cleanse_ctr;\n    }\n#endif\n    return ret;\n}', 'void BN_GENCB_set(BN_GENCB *gencb, int (*callback) (int, int, BN_GENCB *),\n                  void *cb_arg)\n{\n    BN_GENCB *tmp_gencb = gencb;\n    tmp_gencb->ver = 2;\n    tmp_gencb->arg = cb_arg;\n    tmp_gencb->cb.cb_2 = callback;\n}', 'void BN_free(BIGNUM *a)\n{\n    if (a == NULL)\n        return;\n    bn_check_top(a);\n    if (!BN_get_flags(a, BN_FLG_STATIC_DATA))\n        bn_free_d(a);\n    if (a->flags & BN_FLG_MALLOCED)\n        OPENSSL_free(a);\n    else {\n#if OPENSSL_API_COMPAT < 0x00908000L\n        a->flags |= BN_FLG_FREE;\n#endif\n        a->d = NULL;\n    }\n}', 'int BN_get_flags(const BIGNUM *b, int n)\n{\n    return b->flags & n;\n}']