crypto/dsa/dsa_key.c:114: error: MEMORY_LEAK
  memory dynamically allocated by call to `BN_new()` at line 105, column 31 is not reachable after line 114, column 13.
Showing all 120 steps of the trace


crypto/dsa/dsa_key.c:74:1: start of procedure dsa_builtin_keygen()
72.   }
73.   
74. > static int dsa_builtin_keygen(DSA *dsa)
75.   {
76.       int ok = 0;

crypto/dsa/dsa_key.c:76:5: 
74.   static int dsa_builtin_keygen(DSA *dsa)
75.   {
76. >     int ok = 0;
77.       BN_CTX *ctx = NULL;
78.       BIGNUM *pub_key = NULL, *priv_key = NULL;

crypto/dsa/dsa_key.c:77:5: 
75.   {
76.       int ok = 0;
77. >     BN_CTX *ctx = NULL;
78.       BIGNUM *pub_key = NULL, *priv_key = NULL;
79.   

crypto/dsa/dsa_key.c:78:5: 
76.       int ok = 0;
77.       BN_CTX *ctx = NULL;
78. >     BIGNUM *pub_key = NULL, *priv_key = NULL;
79.   
80.       if ((ctx = BN_CTX_new()) == NULL)

crypto/dsa/dsa_key.c:80:9: 
78.       BIGNUM *pub_key = NULL, *priv_key = NULL;
79.   
80. >     if ((ctx = BN_CTX_new()) == NULL)
81.           goto err;
82.   

crypto/bn/bn_ctx.c:188:1: start of procedure BN_CTX_new()
  186.   
  187.   
  188. > BN_CTX *BN_CTX_new(void)
  189.   {
  190.       BN_CTX *ret;

crypto/bn/bn_ctx.c:192:9: 
  190.       BN_CTX *ret;
  191.   
  192. >     if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) {
  193.           BNerr(BN_F_BN_CTX_NEW, ERR_R_MALLOC_FAILURE);
  194.           return NULL;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

crypto/bn/bn_ctx.c:192:9: Taking false branch
  190.       BN_CTX *ret;
  191.   
  192.       if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) {
                 ^
  193.           BNerr(BN_F_BN_CTX_NEW, ERR_R_MALLOC_FAILURE);
  194.           return NULL;

crypto/bn/bn_ctx.c:197:5: 
  195.       }
  196.       /* Initialise the structure */
  197. >     BN_POOL_init(&ret->pool);
  198.       BN_STACK_init(&ret->stack);
  199.       return ret;

crypto/bn/bn_ctx.c:334:1: start of procedure BN_POOL_init()
    332.   /***********/
    333.   
    334. > static void BN_POOL_init(BN_POOL *p)
    335.   {
    336.       p->head = p->current = p->tail = NULL;

crypto/bn/bn_ctx.c:336:5: 
    334.   static void BN_POOL_init(BN_POOL *p)
    335.   {
    336. >     p->head = p->current = p->tail = NULL;
    337.       p->used = p->size = 0;
    338.   }

crypto/bn/bn_ctx.c:337:5: 
    335.   {
    336.       p->head = p->current = p->tail = NULL;
    337. >     p->used = p->size = 0;
    338.   }
    339.   

crypto/bn/bn_ctx.c:338:1: return from a call to BN_POOL_init
    336.       p->head = p->current = p->tail = NULL;
    337.       p->used = p->size = 0;
    338. > }
    339.   
    340.   static void BN_POOL_finish(BN_POOL *p)

crypto/bn/bn_ctx.c:198:5: 
  196.       /* Initialise the structure */
  197.       BN_POOL_init(&ret->pool);
  198. >     BN_STACK_init(&ret->stack);
  199.       return ret;
  200.   }

crypto/bn/bn_ctx.c:293:1: start of procedure BN_STACK_init()
    291.   /************/
    292.   
    293. > static void BN_STACK_init(BN_STACK *st)
    294.   {
    295.       st->indexes = NULL;

crypto/bn/bn_ctx.c:295:5: 
    293.   static void BN_STACK_init(BN_STACK *st)
    294.   {
    295. >     st->indexes = NULL;
    296.       st->depth = st->size = 0;
    297.   }

crypto/bn/bn_ctx.c:296:5: 
    294.   {
    295.       st->indexes = NULL;
    296. >     st->depth = st->size = 0;
    297.   }
    298.   

crypto/bn/bn_ctx.c:297:1: return from a call to BN_STACK_init
    295.       st->indexes = NULL;
    296.       st->depth = st->size = 0;
    297. > }
    298.   
    299.   static void BN_STACK_finish(BN_STACK *st)

crypto/bn/bn_ctx.c:199:5: 
  197.       BN_POOL_init(&ret->pool);
  198.       BN_STACK_init(&ret->stack);
  199. >     return ret;
  200.   }
  201.   

crypto/bn/bn_ctx.c:200:1: return from a call to BN_CTX_new
  198.       BN_STACK_init(&ret->stack);
  199.       return ret;
  200. > }
  201.   
  202.   BN_CTX *BN_CTX_secure_new(void)

crypto/dsa/dsa_key.c:80:9: Taking false branch
78.       BIGNUM *pub_key = NULL, *priv_key = NULL;
79.   
80.       if ((ctx = BN_CTX_new()) == NULL)
              ^
81.           goto err;
82.   

crypto/dsa/dsa_key.c:83:9: Taking false branch
81.           goto err;
82.   
83.       if (dsa->priv_key == NULL) {
              ^
84.           if ((priv_key = BN_secure_new()) == NULL)
85.               goto err;

crypto/dsa/dsa_key.c:87:9: 
85.               goto err;
86.       } else
87. >         priv_key = dsa->priv_key;
88.   
89.       do

crypto/dsa/dsa_key.c:90:14: 
88.   
89.       do
90. >         if (!BN_rand_range(priv_key, dsa->q))
91.               goto err;
92.       while (BN_is_zero(priv_key)) ;

crypto/bn/bn_rand.c:280:1: start of procedure BN_rand_range()
  278.   }
  279.   
  280. > int BN_rand_range(BIGNUM *r, const BIGNUM *range)
  281.   {
  282.       return bn_rand_range(0, r, range);

crypto/bn/bn_rand.c:282:5: Skipping bn_rand_range(): empty list of specs
  280.   int BN_rand_range(BIGNUM *r, const BIGNUM *range)
  281.   {
  282.       return bn_rand_range(0, r, range);
             ^
  283.   }
  284.   

crypto/bn/bn_rand.c:283:1: return from a call to BN_rand_range
  281.   {
  282.       return bn_rand_range(0, r, range);
  283. > }
  284.   
  285.   int BN_pseudo_rand_range(BIGNUM *r, const BIGNUM *range)

crypto/dsa/dsa_key.c:90:14: Taking false branch
88.   
89.       do
90.           if (!BN_rand_range(priv_key, dsa->q))
                   ^
91.               goto err;
92.       while (BN_is_zero(priv_key)) ;

crypto/dsa/dsa_key.c:92:12: 
90.           if (!BN_rand_range(priv_key, dsa->q))
91.               goto err;
92. >     while (BN_is_zero(priv_key)) ;
93.   
94.       if (dsa->pub_key == NULL) {

crypto/bn/bn_lib.c:898:1: start of procedure BN_is_zero()
  896.   }
  897.   
  898. > int BN_is_zero(const BIGNUM *a)
  899.   {
  900.       return a->top == 0;

crypto/bn/bn_lib.c:900:12: Condition is false
  898.   int BN_is_zero(const BIGNUM *a)
  899.   {
  900.       return a->top == 0;
                    ^
  901.   }
  902.   

crypto/bn/bn_lib.c:900:5: 
  898.   int BN_is_zero(const BIGNUM *a)
  899.   {
  900. >     return a->top == 0;
  901.   }
  902.   

crypto/bn/bn_lib.c:901:1: return from a call to BN_is_zero
  899.   {
  900.       return a->top == 0;
  901. > }
  902.   
  903.   int BN_is_one(const BIGNUM *a)

crypto/dsa/dsa_key.c:92:12: Loop condition is false. Leaving loop
90.           if (!BN_rand_range(priv_key, dsa->q))
91.               goto err;
92.       while (BN_is_zero(priv_key)) ;
                 ^
93.   
94.       if (dsa->pub_key == NULL) {

crypto/dsa/dsa_key.c:94:9: Taking true branch
92.       while (BN_is_zero(priv_key)) ;
93.   
94.       if (dsa->pub_key == NULL) {
              ^
95.           if ((pub_key = BN_new()) == NULL)
96.               goto err;

crypto/dsa/dsa_key.c:95:13: 
93.   
94.       if (dsa->pub_key == NULL) {
95. >         if ((pub_key = BN_new()) == NULL)
96.               goto err;
97.       } else

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

crypto/dsa/dsa_key.c:95:13: Taking false branch
93.   
94.       if (dsa->pub_key == NULL) {
95.           if ((pub_key = BN_new()) == NULL)
                  ^
96.               goto err;
97.       } else

crypto/dsa/dsa_key.c:101:9: 
99.   
100.       {
101. >         BIGNUM *local_prk = NULL;
102.           BIGNUM *prk;
103.   

crypto/dsa/dsa_key.c:104:13: Taking true branch
102.           BIGNUM *prk;
103.   
104.           if ((dsa->flags & DSA_FLAG_NO_EXP_CONSTTIME) == 0) {
                   ^
105.               local_prk = prk = BN_new();
106.               if (local_prk == NULL)

crypto/dsa/dsa_key.c:105:13: 
103.   
104.           if ((dsa->flags & DSA_FLAG_NO_EXP_CONSTTIME) == 0) {
105. >             local_prk = prk = BN_new();
106.               if (local_prk == NULL)
107.                   goto err;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

crypto/dsa/dsa_key.c:106:17: Taking false branch
104.           if ((dsa->flags & DSA_FLAG_NO_EXP_CONSTTIME) == 0) {
105.               local_prk = prk = BN_new();
106.               if (local_prk == NULL)
                       ^
107.                   goto err;
108.               BN_with_flags(prk, priv_key, BN_FLG_CONSTTIME);

crypto/dsa/dsa_key.c:108:13: 
106.               if (local_prk == NULL)
107.                   goto err;
108. >             BN_with_flags(prk, priv_key, BN_FLG_CONSTTIME);
109.           } else {
110.               prk = priv_key;

crypto/bn/bn_lib.c:929:1: start of procedure BN_with_flags()
  927.   }
  928.   
  929. > void BN_with_flags(BIGNUM *dest, const BIGNUM *b, int flags)
  930.   {
  931.       dest->d = b->d;

crypto/bn/bn_lib.c:931:5: 
  929.   void BN_with_flags(BIGNUM *dest, const BIGNUM *b, int flags)
  930.   {
  931. >     dest->d = b->d;
  932.       dest->top = b->top;
  933.       dest->dmax = b->dmax;

crypto/bn/bn_lib.c:932:5: 
  930.   {
  931.       dest->d = b->d;
  932. >     dest->top = b->top;
  933.       dest->dmax = b->dmax;
  934.       dest->neg = b->neg;

crypto/bn/bn_lib.c:933:5: 
  931.       dest->d = b->d;
  932.       dest->top = b->top;
  933. >     dest->dmax = b->dmax;
  934.       dest->neg = b->neg;
  935.       dest->flags = ((dest->flags & BN_FLG_MALLOCED)

crypto/bn/bn_lib.c:934:5: 
  932.       dest->top = b->top;
  933.       dest->dmax = b->dmax;
  934. >     dest->neg = b->neg;
  935.       dest->flags = ((dest->flags & BN_FLG_MALLOCED)
  936.                      | (b->flags & ~BN_FLG_MALLOCED)

crypto/bn/bn_lib.c:935:5: 
  933.       dest->dmax = b->dmax;
  934.       dest->neg = b->neg;
  935. >     dest->flags = ((dest->flags & BN_FLG_MALLOCED)
  936.                      | (b->flags & ~BN_FLG_MALLOCED)
  937.                      | BN_FLG_STATIC_DATA | flags);

crypto/bn/bn_lib.c:938:1: return from a call to BN_with_flags
  936.                      | (b->flags & ~BN_FLG_MALLOCED)
  937.                      | BN_FLG_STATIC_DATA | flags);
  938. > }
  939.   
  940.   BN_GENCB *BN_GENCB_new(void)

crypto/dsa/dsa_key.c:113:14: Taking true branch
111.           }
112.   
113.           if (!BN_mod_exp(pub_key, dsa->g, prk, dsa->p, ctx)) {
                    ^
114.               BN_free(local_prk);
115.               goto err;

crypto/dsa/dsa_key.c:114:13: 
112.   
113.           if (!BN_mod_exp(pub_key, dsa->g, prk, dsa->p, ctx)) {
114. >             BN_free(local_prk);
115.               goto err;
116.           }

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

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

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

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

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

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

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

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

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

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

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

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

static int dsa_builtin_keygen(DSA *dsa)
{
    int ok = 0;
    BN_CTX *ctx = NULL;
    BIGNUM *pub_key = NULL, *priv_key = NULL;
    if ((ctx = BN_CTX_new()) == NULL)
        goto err;
    if (dsa->priv_key == NULL) {
        if ((priv_key = BN_secure_new()) == NULL)
            goto err;
    } else
        priv_key = dsa->priv_key;
    do
        if (!BN_rand_range(priv_key, dsa->q))
            goto err;
    while (BN_is_zero(priv_key)) ;
    if (dsa->pub_key == NULL) {
        if ((pub_key = BN_new()) == NULL)
            goto err;
    } else
        pub_key = dsa->pub_key;
    {
        BIGNUM *local_prk = NULL;
        BIGNUM *prk;
        if ((dsa->flags & DSA_FLAG_NO_EXP_CONSTTIME) == 0) {
            local_prk = prk = BN_new();
            if (local_prk == NULL)
                goto err;
            BN_with_flags(prk, priv_key, BN_FLG_CONSTTIME);
        } else {
            prk = priv_key;
        }
        if (!BN_mod_exp(pub_key, dsa->g, prk, dsa->p, ctx)) {
            BN_free(local_prk);
            goto err;
        }
        BN_free(local_prk);
    }
    dsa->priv_key = priv_key;
    dsa->pub_key = pub_key;
    ok = 1;
 err:
    if (pub_key != dsa->pub_key)
        BN_free(pub_key);
    if (priv_key != dsa->priv_key)
        BN_free(priv_key);
    BN_CTX_free(ctx);
    return (ok);
}
['static int dsa_builtin_keygen(DSA *dsa)\n{\n    int ok = 0;\n    BN_CTX *ctx = NULL;\n    BIGNUM *pub_key = NULL, *priv_key = NULL;\n    if ((ctx = BN_CTX_new()) == NULL)\n        goto err;\n    if (dsa->priv_key == NULL) {\n        if ((priv_key = BN_secure_new()) == NULL)\n            goto err;\n    } else\n        priv_key = dsa->priv_key;\n    do\n        if (!BN_rand_range(priv_key, dsa->q))\n            goto err;\n    while (BN_is_zero(priv_key)) ;\n    if (dsa->pub_key == NULL) {\n        if ((pub_key = BN_new()) == NULL)\n            goto err;\n    } else\n        pub_key = dsa->pub_key;\n    {\n        BIGNUM *local_prk = NULL;\n        BIGNUM *prk;\n        if ((dsa->flags & DSA_FLAG_NO_EXP_CONSTTIME) == 0) {\n            local_prk = prk = BN_new();\n            if (local_prk == NULL)\n                goto err;\n            BN_with_flags(prk, priv_key, BN_FLG_CONSTTIME);\n        } else {\n            prk = priv_key;\n        }\n        if (!BN_mod_exp(pub_key, dsa->g, prk, dsa->p, ctx)) {\n            BN_free(local_prk);\n            goto err;\n        }\n        BN_free(local_prk);\n    }\n    dsa->priv_key = priv_key;\n    dsa->pub_key = pub_key;\n    ok = 1;\n err:\n    if (pub_key != dsa->pub_key)\n        BN_free(pub_key);\n    if (priv_key != dsa->priv_key)\n        BN_free(priv_key);\n    BN_CTX_free(ctx);\n    return (ok);\n}', 'BN_CTX *BN_CTX_new(void)\n{\n    BN_CTX *ret;\n    if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) {\n        BNerr(BN_F_BN_CTX_NEW, ERR_R_MALLOC_FAILURE);\n        return NULL;\n    }\n    BN_POOL_init(&ret->pool);\n    BN_STACK_init(&ret->stack);\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}', 'static void BN_POOL_init(BN_POOL *p)\n{\n    p->head = p->current = p->tail = NULL;\n    p->used = p->size = 0;\n}', 'static void BN_STACK_init(BN_STACK *st)\n{\n    st->indexes = NULL;\n    st->depth = st->size = 0;\n}', 'int BN_rand_range(BIGNUM *r, const BIGNUM *range)\n{\n    return bn_rand_range(0, r, range);\n}', 'int BN_is_zero(const BIGNUM *a)\n{\n    return a->top == 0;\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 BN_with_flags(BIGNUM *dest, const BIGNUM *b, int flags)\n{\n    dest->d = b->d;\n    dest->top = b->top;\n    dest->dmax = b->dmax;\n    dest->neg = b->neg;\n    dest->flags = ((dest->flags & BN_FLG_MALLOCED)\n                   | (b->flags & ~BN_FLG_MALLOCED)\n                   | BN_FLG_STATIC_DATA | flags);\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}']