crypto/ec/ec_lib.c:987: error: MEMORY_LEAK
  memory dynamically allocated to `group->mont_data` by call to `BN_MONT_CTX_new()` at line 981, column 24 is not reachable after line 987, column 9.
Showing all 57 steps of the trace


crypto/ec/ec_lib.c:970:1: start of procedure ec_precompute_mont_data()
968.    * returns one on success. On error it returns zero.
969.    */
970. > int ec_precompute_mont_data(EC_GROUP *group)
971.   {
972.       BN_CTX *ctx = BN_CTX_new();

crypto/ec/ec_lib.c:972:5: Skipping BN_CTX_new(): empty list of specs
970.   int ec_precompute_mont_data(EC_GROUP *group)
971.   {
972.       BN_CTX *ctx = BN_CTX_new();
           ^
973.       int ret = 0;
974.   

crypto/ec/ec_lib.c:973:5: 
971.   {
972.       BN_CTX *ctx = BN_CTX_new();
973. >     int ret = 0;
974.   
975.       BN_MONT_CTX_free(group->mont_data);

crypto/ec/ec_lib.c:975:5: 
973.       int ret = 0;
974.   
975. >     BN_MONT_CTX_free(group->mont_data);
976.       group->mont_data = NULL;
977.   

crypto/bn/bn_mont.c:235:1: start of procedure BN_MONT_CTX_free()
  233.   }
  234.   
  235. > void BN_MONT_CTX_free(BN_MONT_CTX *mont)
  236.   {
  237.       if (mont == NULL)

crypto/bn/bn_mont.c:237:9: Taking false branch
  235.   void BN_MONT_CTX_free(BN_MONT_CTX *mont)
  236.   {
  237.       if (mont == NULL)
                 ^
  238.           return;
  239.   

crypto/bn/bn_mont.c:240:5: Skipping BN_clear_free(): empty list of specs
  238.           return;
  239.   
  240.       BN_clear_free(&(mont->RR));
             ^
  241.       BN_clear_free(&(mont->N));
  242.       BN_clear_free(&(mont->Ni));

crypto/bn/bn_mont.c:241:5: Skipping BN_clear_free(): empty list of specs
  239.   
  240.       BN_clear_free(&(mont->RR));
  241.       BN_clear_free(&(mont->N));
             ^
  242.       BN_clear_free(&(mont->Ni));
  243.       if (mont->flags & BN_FLG_MALLOCED)

crypto/bn/bn_mont.c:242:5: Skipping BN_clear_free(): empty list of specs
  240.       BN_clear_free(&(mont->RR));
  241.       BN_clear_free(&(mont->N));
  242.       BN_clear_free(&(mont->Ni));
             ^
  243.       if (mont->flags & BN_FLG_MALLOCED)
  244.           OPENSSL_free(mont);

crypto/bn/bn_mont.c:243:9: Taking true branch
  241.       BN_clear_free(&(mont->N));
  242.       BN_clear_free(&(mont->Ni));
  243.       if (mont->flags & BN_FLG_MALLOCED)
                 ^
  244.           OPENSSL_free(mont);
  245.   }

crypto/bn/bn_mont.c:244:9: 
  242.       BN_clear_free(&(mont->Ni));
  243.       if (mont->flags & BN_FLG_MALLOCED)
  244. >         OPENSSL_free(mont);
  245.   }
  246.   

crypto/mem.c:253:1: start of procedure CRYPTO_free()
    251.   }
    252.   
    253. > void CRYPTO_free(void *str, const char *file, int line)
    254.   {
    255.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:255:9: Taking false branch
    253.   void CRYPTO_free(void *str, const char *file, int line)
    254.   {
    255.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    256.           free_impl(str, file, line);
    257.           return;

crypto/mem.c:269:5: 
    267.       }
    268.   #else
    269. >     free(str);
    270.   #endif
    271.   }

crypto/mem.c:271:1: return from a call to CRYPTO_free
    269.       free(str);
    270.   #endif
    271. > }
    272.   
    273.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

crypto/bn/bn_mont.c:243:5: 
  241.       BN_clear_free(&(mont->N));
  242.       BN_clear_free(&(mont->Ni));
  243. >     if (mont->flags & BN_FLG_MALLOCED)
  244.           OPENSSL_free(mont);
  245.   }

crypto/bn/bn_mont.c:245:1: return from a call to BN_MONT_CTX_free
  243.       if (mont->flags & BN_FLG_MALLOCED)
  244.           OPENSSL_free(mont);
  245. > }
  246.   
  247.   int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx)

crypto/ec/ec_lib.c:976:5: 
974.   
975.       BN_MONT_CTX_free(group->mont_data);
976. >     group->mont_data = NULL;
977.   
978.       if (ctx == NULL)

crypto/ec/ec_lib.c:978:9: Taking false branch
976.       group->mont_data = NULL;
977.   
978.       if (ctx == NULL)
               ^
979.           goto err;
980.   

crypto/ec/ec_lib.c:981:5: 
979.           goto err;
980.   
981. >     group->mont_data = BN_MONT_CTX_new();
982.       if (group->mont_data == NULL)
983.           goto err;

crypto/bn/bn_mont.c:213:1: start of procedure BN_MONT_CTX_new()
  211.   }
  212.   
  213. > BN_MONT_CTX *BN_MONT_CTX_new(void)
  214.   {
  215.       BN_MONT_CTX *ret;

crypto/bn/bn_mont.c:217:9: 
  215.       BN_MONT_CTX *ret;
  216.   
  217. >     if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL)
  218.           return (NULL);
  219.   

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

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

crypto/mem.c:162:9: Taking false branch
    160.       void *ret = NULL;
    161.   
    162.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                   ^
    163.           return malloc_impl(num, file, line);
    164.   

crypto/mem.c:165:9: Taking false branch
    163.           return malloc_impl(num, file, line);
    164.   
    165.       if (num == 0)
                   ^
    166.           return NULL;
    167.   

crypto/mem.c:169:5: 
    167.   
    168.       FAILTEST();
    169. >     allow_customize = 0;
    170.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
    171.       if (call_malloc_debug) {

crypto/mem.c:179:5: 
    177.       }
    178.   #else
    179. >     osslargused(file); osslargused(line);
    180.       ret = malloc(num);
    181.   #endif

crypto/mem.c:179:24: 
    177.       }
    178.   #else
    179. >     osslargused(file); osslargused(line);
    180.       ret = malloc(num);
    181.   #endif

crypto/mem.c:180:5: 
    178.   #else
    179.       osslargused(file); osslargused(line);
    180. >     ret = malloc(num);
    181.   #endif
    182.   

crypto/mem.c:183:5: 
    181.   #endif
    182.   
    183. >     return ret;
    184.   }
    185.   

crypto/mem.c:184:1: return from a call to CRYPTO_malloc
    182.   
    183.       return ret;
    184. > }
    185.   
    186.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/bn/bn_mont.c:217:9: Taking false branch
  215.       BN_MONT_CTX *ret;
  216.   
  217.       if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL)
                 ^
  218.           return (NULL);
  219.   

crypto/bn/bn_mont.c:220:5: 
  218.           return (NULL);
  219.   
  220. >     BN_MONT_CTX_init(ret);
  221.       ret->flags = BN_FLG_MALLOCED;
  222.       return (ret);

crypto/bn/bn_mont.c:225:1: start of procedure BN_MONT_CTX_init()
    223.   }
    224.   
    225. > void BN_MONT_CTX_init(BN_MONT_CTX *ctx)
    226.   {
    227.       ctx->ri = 0;

crypto/bn/bn_mont.c:227:5: 
    225.   void BN_MONT_CTX_init(BN_MONT_CTX *ctx)
    226.   {
    227. >     ctx->ri = 0;
    228.       bn_init(&(ctx->RR));
    229.       bn_init(&(ctx->N));

crypto/bn/bn_mont.c:228:5: Skipping bn_init(): empty list of specs
    226.   {
    227.       ctx->ri = 0;
    228.       bn_init(&(ctx->RR));
               ^
    229.       bn_init(&(ctx->N));
    230.       bn_init(&(ctx->Ni));

crypto/bn/bn_mont.c:229:5: Skipping bn_init(): empty list of specs
    227.       ctx->ri = 0;
    228.       bn_init(&(ctx->RR));
    229.       bn_init(&(ctx->N));
               ^
    230.       bn_init(&(ctx->Ni));
    231.       ctx->n0[0] = ctx->n0[1] = 0;

crypto/bn/bn_mont.c:230:5: Skipping bn_init(): empty list of specs
    228.       bn_init(&(ctx->RR));
    229.       bn_init(&(ctx->N));
    230.       bn_init(&(ctx->Ni));
               ^
    231.       ctx->n0[0] = ctx->n0[1] = 0;
    232.       ctx->flags = 0;

crypto/bn/bn_mont.c:231:5: 
    229.       bn_init(&(ctx->N));
    230.       bn_init(&(ctx->Ni));
    231. >     ctx->n0[0] = ctx->n0[1] = 0;
    232.       ctx->flags = 0;
    233.   }

crypto/bn/bn_mont.c:232:5: 
    230.       bn_init(&(ctx->Ni));
    231.       ctx->n0[0] = ctx->n0[1] = 0;
    232. >     ctx->flags = 0;
    233.   }
    234.   

crypto/bn/bn_mont.c:233:1: return from a call to BN_MONT_CTX_init
    231.       ctx->n0[0] = ctx->n0[1] = 0;
    232.       ctx->flags = 0;
    233. > }
    234.   
    235.   void BN_MONT_CTX_free(BN_MONT_CTX *mont)

crypto/bn/bn_mont.c:221:5: 
  219.   
  220.       BN_MONT_CTX_init(ret);
  221. >     ret->flags = BN_FLG_MALLOCED;
  222.       return (ret);
  223.   }

crypto/bn/bn_mont.c:222:5: 
  220.       BN_MONT_CTX_init(ret);
  221.       ret->flags = BN_FLG_MALLOCED;
  222. >     return (ret);
  223.   }
  224.   

crypto/bn/bn_mont.c:223:1: return from a call to BN_MONT_CTX_new
  221.       ret->flags = BN_FLG_MALLOCED;
  222.       return (ret);
  223. > }
  224.   
  225.   void BN_MONT_CTX_init(BN_MONT_CTX *ctx)

crypto/ec/ec_lib.c:982:9: Taking false branch
980.   
981.       group->mont_data = BN_MONT_CTX_new();
982.       if (group->mont_data == NULL)
               ^
983.           goto err;
984.   

crypto/ec/ec_lib.c:985:10: Taking true branch
983.           goto err;
984.   
985.       if (!BN_MONT_CTX_set(group->mont_data, group->order, ctx)) {
                ^
986.           BN_MONT_CTX_free(group->mont_data);
987.           group->mont_data = NULL;

crypto/ec/ec_lib.c:986:9: 
984.   
985.       if (!BN_MONT_CTX_set(group->mont_data, group->order, ctx)) {
986. >         BN_MONT_CTX_free(group->mont_data);
987.           group->mont_data = NULL;
988.           goto err;

crypto/bn/bn_mont.c:235:1: start of procedure BN_MONT_CTX_free()
  233.   }
  234.   
  235. > void BN_MONT_CTX_free(BN_MONT_CTX *mont)
  236.   {
  237.       if (mont == NULL)

crypto/bn/bn_mont.c:237:9: Taking false branch
  235.   void BN_MONT_CTX_free(BN_MONT_CTX *mont)
  236.   {
  237.       if (mont == NULL)
                 ^
  238.           return;
  239.   

crypto/bn/bn_mont.c:240:5: Skipping BN_clear_free(): empty list of specs
  238.           return;
  239.   
  240.       BN_clear_free(&(mont->RR));
             ^
  241.       BN_clear_free(&(mont->N));
  242.       BN_clear_free(&(mont->Ni));

crypto/bn/bn_mont.c:241:5: Skipping BN_clear_free(): empty list of specs
  239.   
  240.       BN_clear_free(&(mont->RR));
  241.       BN_clear_free(&(mont->N));
             ^
  242.       BN_clear_free(&(mont->Ni));
  243.       if (mont->flags & BN_FLG_MALLOCED)

crypto/bn/bn_mont.c:242:5: Skipping BN_clear_free(): empty list of specs
  240.       BN_clear_free(&(mont->RR));
  241.       BN_clear_free(&(mont->N));
  242.       BN_clear_free(&(mont->Ni));
             ^
  243.       if (mont->flags & BN_FLG_MALLOCED)
  244.           OPENSSL_free(mont);

crypto/bn/bn_mont.c:243:9: Taking false branch
  241.       BN_clear_free(&(mont->N));
  242.       BN_clear_free(&(mont->Ni));
  243.       if (mont->flags & BN_FLG_MALLOCED)
                 ^
  244.           OPENSSL_free(mont);
  245.   }

crypto/bn/bn_mont.c:243:5: 
  241.       BN_clear_free(&(mont->N));
  242.       BN_clear_free(&(mont->Ni));
  243. >     if (mont->flags & BN_FLG_MALLOCED)
  244.           OPENSSL_free(mont);
  245.   }

crypto/bn/bn_mont.c:245:1: return from a call to BN_MONT_CTX_free
  243.       if (mont->flags & BN_FLG_MALLOCED)
  244.           OPENSSL_free(mont);
  245. > }
  246.   
  247.   int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx)

crypto/ec/ec_lib.c:987:9: 
985.       if (!BN_MONT_CTX_set(group->mont_data, group->order, ctx)) {
986.           BN_MONT_CTX_free(group->mont_data);
987. >         group->mont_data = NULL;
988.           goto err;
989.       }
