crypto/dsa/dsa_gen.c:660: error: MEMORY_LEAK
  memory dynamically allocated to `return` by call to `BN_CTX_new()` at line 653, column 11 is not reachable after line 660, column 9.
Showing all 77 steps of the trace


crypto/dsa/dsa_gen.c:647:1: start of procedure dsa_paramgen_check_g()
645.   }
646.   
647. > int dsa_paramgen_check_g(DSA *dsa)
648.   {
649.       BN_CTX *ctx;

crypto/dsa/dsa_gen.c:651:5: 
649.       BN_CTX *ctx;
650.       BIGNUM *tmp;
651. >     BN_MONT_CTX *mont = NULL;
652.       int rv = -1;
653.       ctx = BN_CTX_new();

crypto/dsa/dsa_gen.c:652:5: 
650.       BIGNUM *tmp;
651.       BN_MONT_CTX *mont = NULL;
652. >     int rv = -1;
653.       ctx = BN_CTX_new();
654.       if (ctx == NULL)

crypto/dsa/dsa_gen.c:653:5: 
651.       BN_MONT_CTX *mont = NULL;
652.       int rv = -1;
653. >     ctx = BN_CTX_new();
654.       if (ctx == NULL)
655.           return -1;

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

crypto/bn/bn_ctx.c:193:9: 
  191.       BN_CTX *ret;
  192.   
  193. >     if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) {
  194.           BNerr(BN_F_BN_CTX_NEW, ERR_R_MALLOC_FAILURE);
  195.           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.   #ifdef 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_ctx.c:193:9: Taking false branch
  191.       BN_CTX *ret;
  192.   
  193.       if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) {
                 ^
  194.           BNerr(BN_F_BN_CTX_NEW, ERR_R_MALLOC_FAILURE);
  195.           return NULL;

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

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

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

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

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

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

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

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

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

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

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

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

crypto/dsa/dsa_gen.c:654:9: Taking false branch
652.       int rv = -1;
653.       ctx = BN_CTX_new();
654.       if (ctx == NULL)
               ^
655.           return -1;
656.       BN_CTX_start(ctx);

crypto/dsa/dsa_gen.c:656:5: 
654.       if (ctx == NULL)
655.           return -1;
656. >     BN_CTX_start(ctx);
657.       if (BN_cmp(dsa->g, BN_value_one()) <= 0)
658.           return 0;

crypto/bn/bn_ctx.c:236:1: start of procedure BN_CTX_start()
  234.   }
  235.   
  236. > void BN_CTX_start(BN_CTX *ctx)
  237.   {
  238.       CTXDBG_ENTRY("BN_CTX_start", ctx);

crypto/bn/bn_ctx.c:240:9: Taking false branch
  238.       CTXDBG_ENTRY("BN_CTX_start", ctx);
  239.       /* If we're already overflowing ... */
  240.       if (ctx->err_stack || ctx->too_many)
                 ^
  241.           ctx->err_stack++;
  242.       /* (Try to) get a new frame pointer */

crypto/bn/bn_ctx.c:240:27: Taking false branch
  238.       CTXDBG_ENTRY("BN_CTX_start", ctx);
  239.       /* If we're already overflowing ... */
  240.       if (ctx->err_stack || ctx->too_many)
                                   ^
  241.           ctx->err_stack++;
  242.       /* (Try to) get a new frame pointer */

crypto/bn/bn_ctx.c:243:15: 
  241.           ctx->err_stack++;
  242.       /* (Try to) get a new frame pointer */
  243. >     else if (!BN_STACK_push(&ctx->stack, ctx->used)) {
  244.           BNerr(BN_F_BN_CTX_START, BN_R_TOO_MANY_TEMPORARY_VARIABLES);
  245.           ctx->err_stack++;

crypto/bn/bn_ctx.c:307:1: start of procedure BN_STACK_push()
    305.   
    306.   
    307. > static int BN_STACK_push(BN_STACK *st, unsigned int idx)
    308.   {
    309.       if (st->depth == st->size) {

crypto/bn/bn_ctx.c:309:9: Taking true branch
    307.   static int BN_STACK_push(BN_STACK *st, unsigned int idx)
    308.   {
    309.       if (st->depth == st->size) {
                   ^
    310.           /* Need to expand */
    311.           unsigned int newsize =

crypto/bn/bn_ctx.c:312:13: Condition is false
    310.           /* Need to expand */
    311.           unsigned int newsize =
    312.               st->size ? (st->size * 3 / 2) : BN_CTX_START_FRAMES;
                       ^
    313.           unsigned int *newitems = OPENSSL_malloc(sizeof(*newitems) * newsize);
    314.           if (newitems == NULL)

crypto/bn/bn_ctx.c:311:9: 
    309.       if (st->depth == st->size) {
    310.           /* Need to expand */
    311. >         unsigned int newsize =
    312.               st->size ? (st->size * 3 / 2) : BN_CTX_START_FRAMES;
    313.           unsigned int *newitems = OPENSSL_malloc(sizeof(*newitems) * newsize);

crypto/bn/bn_ctx.c:313:9: 
    311.           unsigned int newsize =
    312.               st->size ? (st->size * 3 / 2) : BN_CTX_START_FRAMES;
    313. >         unsigned int *newitems = OPENSSL_malloc(sizeof(*newitems) * newsize);
    314.           if (newitems == NULL)
    315.               return 0;

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.   #ifdef 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/bn/bn_ctx.c:314:13: Taking false branch
    312.               st->size ? (st->size * 3 / 2) : BN_CTX_START_FRAMES;
    313.           unsigned int *newitems = OPENSSL_malloc(sizeof(*newitems) * newsize);
    314.           if (newitems == NULL)
                       ^
    315.               return 0;
    316.           if (st->depth)

crypto/bn/bn_ctx.c:316:13: Taking false branch
    314.           if (newitems == NULL)
    315.               return 0;
    316.           if (st->depth)
                       ^
    317.               memcpy(newitems, st->indexes, sizeof(*newitems) * st->depth);
    318.           OPENSSL_free(st->indexes);

crypto/bn/bn_ctx.c:318:9: 
    316.           if (st->depth)
    317.               memcpy(newitems, st->indexes, sizeof(*newitems) * st->depth);
    318. >         OPENSSL_free(st->indexes);
    319.           st->indexes = newitems;
    320.           st->size = newsize;

crypto/mem.c:234:1: start of procedure CRYPTO_free()
      232.   }
      233.   
      234. > void CRYPTO_free(void *str)
      235.   {
      236.   #ifdef CRYPTO_MDEBUG

crypto/mem.c:245:5: 
      243.       }
      244.   #else
      245. >     free(str);
      246.   #endif
      247.   }

crypto/mem.c:247:1: return from a call to CRYPTO_free
      245.       free(str);
      246.   #endif
      247. > }
      248.   
      249.   void CRYPTO_clear_free(void *str, size_t num)

crypto/bn/bn_ctx.c:319:9: 
    317.               memcpy(newitems, st->indexes, sizeof(*newitems) * st->depth);
    318.           OPENSSL_free(st->indexes);
    319. >         st->indexes = newitems;
    320.           st->size = newsize;
    321.       }

crypto/bn/bn_ctx.c:320:9: 
    318.           OPENSSL_free(st->indexes);
    319.           st->indexes = newitems;
    320. >         st->size = newsize;
    321.       }
    322.       st->indexes[(st->depth)++] = idx;

crypto/bn/bn_ctx.c:322:5: 
    320.           st->size = newsize;
    321.       }
    322. >     st->indexes[(st->depth)++] = idx;
    323.       return 1;
    324.   }

crypto/bn/bn_ctx.c:323:5: 
    321.       }
    322.       st->indexes[(st->depth)++] = idx;
    323. >     return 1;
    324.   }
    325.   

crypto/bn/bn_ctx.c:324:1: return from a call to BN_STACK_push
    322.       st->indexes[(st->depth)++] = idx;
    323.       return 1;
    324. > }
    325.   
    326.   static unsigned int BN_STACK_pop(BN_STACK *st)

crypto/bn/bn_ctx.c:243:15: Taking false branch
  241.           ctx->err_stack++;
  242.       /* (Try to) get a new frame pointer */
  243.       else if (!BN_STACK_push(&ctx->stack, ctx->used)) {
                       ^
  244.           BNerr(BN_F_BN_CTX_START, BN_R_TOO_MANY_TEMPORARY_VARIABLES);
  245.           ctx->err_stack++;

crypto/bn/bn_ctx.c:240:5: 
  238.       CTXDBG_ENTRY("BN_CTX_start", ctx);
  239.       /* If we're already overflowing ... */
  240. >     if (ctx->err_stack || ctx->too_many)
  241.           ctx->err_stack++;
  242.       /* (Try to) get a new frame pointer */

crypto/bn/bn_ctx.c:248:1: return from a call to BN_CTX_start
  246.       }
  247.       CTXDBG_EXIT(ctx);
  248. > }
  249.   
  250.   void BN_CTX_end(BN_CTX *ctx)

crypto/dsa/dsa_gen.c:657:9: 
655.           return -1;
656.       BN_CTX_start(ctx);
657. >     if (BN_cmp(dsa->g, BN_value_one()) <= 0)
658.           return 0;
659.       if (BN_cmp(dsa->g, dsa->p) >= 0)

crypto/bn/bn_lib.c:134:1: start of procedure BN_value_one()
  132.   #endif
  133.   
  134. > const BIGNUM *BN_value_one(void)
  135.   {
  136.       static const BN_ULONG data_one = 1L;

crypto/bn/bn_lib.c:136:5: 
  134.   const BIGNUM *BN_value_one(void)
  135.   {
  136. >     static const BN_ULONG data_one = 1L;
  137.       static const BIGNUM const_one =
  138.           { (BN_ULONG *)&data_one, 1, 1, 0, BN_FLG_STATIC_DATA };

crypto/bn/bn_lib.c:137:5: 
  135.   {
  136.       static const BN_ULONG data_one = 1L;
  137. >     static const BIGNUM const_one =
  138.           { (BN_ULONG *)&data_one, 1, 1, 0, BN_FLG_STATIC_DATA };
  139.   

crypto/bn/bn_lib.c:140:5: 
  138.           { (BN_ULONG *)&data_one, 1, 1, 0, BN_FLG_STATIC_DATA };
  139.   
  140. >     return (&const_one);
  141.   }
  142.   

crypto/bn/bn_lib.c:141:1: return from a call to BN_value_one
  139.   
  140.       return (&const_one);
  141. > }
  142.   
  143.   int BN_num_bits_word(BN_ULONG l)

crypto/dsa/dsa_gen.c:657:9: Taking false branch
655.           return -1;
656.       BN_CTX_start(ctx);
657.       if (BN_cmp(dsa->g, BN_value_one()) <= 0)
               ^
658.           return 0;
659.       if (BN_cmp(dsa->g, dsa->p) >= 0)

crypto/dsa/dsa_gen.c:659:9: Taking true branch
657.       if (BN_cmp(dsa->g, BN_value_one()) <= 0)
658.           return 0;
659.       if (BN_cmp(dsa->g, dsa->p) >= 0)
               ^
660.           return 0;
661.       tmp = BN_CTX_get(ctx);

crypto/dsa/dsa_gen.c:660:9: 
658.           return 0;
659.       if (BN_cmp(dsa->g, dsa->p) >= 0)
660. >         return 0;
661.       tmp = BN_CTX_get(ctx);
662.       if (!tmp)
