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


crypto/ec/ec_lib.c:1001:1: start of procedure ec_precompute_mont_data()
999.    * returns one on success. On error it returns zero.
1000.    */
1001. > static int ec_precompute_mont_data(EC_GROUP *group)
1002.   {
1003.       BN_CTX *ctx = BN_CTX_new();

crypto/ec/ec_lib.c:1003:5: Skipping BN_CTX_new(): empty list of specs
1001.   static int ec_precompute_mont_data(EC_GROUP *group)
1002.   {
1003.       BN_CTX *ctx = BN_CTX_new();
            ^
1004.       int ret = 0;
1005.   

crypto/ec/ec_lib.c:1004:5: 
1002.   {
1003.       BN_CTX *ctx = BN_CTX_new();
1004. >     int ret = 0;
1005.   
1006.       BN_MONT_CTX_free(group->mont_data);

crypto/ec/ec_lib.c:1006:5: Skipping BN_MONT_CTX_free(): empty list of specs
1004.       int ret = 0;
1005.   
1006.       BN_MONT_CTX_free(group->mont_data);
            ^
1007.       group->mont_data = NULL;
1008.   

crypto/ec/ec_lib.c:1007:5: 
1005.   
1006.       BN_MONT_CTX_free(group->mont_data);
1007. >     group->mont_data = NULL;
1008.   
1009.       if (ctx == NULL)

crypto/ec/ec_lib.c:1009:9: Taking false branch
1007.       group->mont_data = NULL;
1008.   
1009.       if (ctx == NULL)
                ^
1010.           goto err;
1011.   

crypto/ec/ec_lib.c:1012:5: 
1010.           goto err;
1011.   
1012. >     group->mont_data = BN_MONT_CTX_new();
1013.       if (group->mont_data == NULL)
1014.           goto err;

crypto/bn/bn_mont.c:228:1: start of procedure BN_MONT_CTX_new()
  226.   }
  227.   
  228. > BN_MONT_CTX *BN_MONT_CTX_new(void)
  229.   {
  230.       BN_MONT_CTX *ret;

crypto/bn/bn_mont.c:232:9: 
  230.       BN_MONT_CTX *ret;
  231.   
  232. >     if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL) {
  233.           BNerr(BN_F_BN_MONT_CTX_NEW, ERR_R_MALLOC_FAILURE);
  234.           return NULL;

crypto/mem.c:192:1: start of procedure CRYPTO_malloc()
    190.   #endif
    191.   
    192. > void *CRYPTO_malloc(size_t num, const char *file, int line)
    193.   {
    194.       void *ret = NULL;

crypto/mem.c:194:5: 
    192.   void *CRYPTO_malloc(size_t num, const char *file, int line)
    193.   {
    194. >     void *ret = NULL;
    195.   
    196.       INCREMENT(malloc_count);

crypto/mem.c:197:9: Taking false branch
    195.   
    196.       INCREMENT(malloc_count);
    197.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                   ^
    198.           return malloc_impl(num, file, line);
    199.   

crypto/mem.c:200:9: Taking false branch
    198.           return malloc_impl(num, file, line);
    199.   
    200.       if (num == 0)
                   ^
    201.           return NULL;
    202.   

crypto/mem.c:204:9: Taking false branch
    202.   
    203.       FAILTEST();
    204.       if (allow_customize) {
                   ^
    205.           /*
    206.            * Disallow customization after the first allocation. We only set this

crypto/mem.c:221:5: 
    219.       }
    220.   #else
    221. >     (void)(file); (void)(line);
    222.       ret = malloc(num);
    223.   #endif

crypto/mem.c:221:19: 
    219.       }
    220.   #else
    221. >     (void)(file); (void)(line);
    222.       ret = malloc(num);
    223.   #endif

crypto/mem.c:222:5: 
    220.   #else
    221.       (void)(file); (void)(line);
    222. >     ret = malloc(num);
    223.   #endif
    224.   

crypto/mem.c:225:5: 
    223.   #endif
    224.   
    225. >     return ret;
    226.   }
    227.   

crypto/mem.c:226:1: return from a call to CRYPTO_malloc
    224.   
    225.       return ret;
    226. > }
    227.   
    228.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/bn/bn_mont.c:232:9: Taking false branch
  230.       BN_MONT_CTX *ret;
  231.   
  232.       if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL) {
                 ^
  233.           BNerr(BN_F_BN_MONT_CTX_NEW, ERR_R_MALLOC_FAILURE);
  234.           return NULL;

crypto/bn/bn_mont.c:237:5: 
  235.       }
  236.   
  237. >     BN_MONT_CTX_init(ret);
  238.       ret->flags = BN_FLG_MALLOCED;
  239.       return ret;

crypto/bn/bn_mont.c:242:1: start of procedure BN_MONT_CTX_init()
    240.   }
    241.   
    242. > void BN_MONT_CTX_init(BN_MONT_CTX *ctx)
    243.   {
    244.       ctx->ri = 0;

crypto/bn/bn_mont.c:244:5: 
    242.   void BN_MONT_CTX_init(BN_MONT_CTX *ctx)
    243.   {
    244. >     ctx->ri = 0;
    245.       bn_init(&ctx->RR);
    246.       bn_init(&ctx->N);

crypto/bn/bn_mont.c:245:5: Skipping bn_init(): empty list of specs
    243.   {
    244.       ctx->ri = 0;
    245.       bn_init(&ctx->RR);
               ^
    246.       bn_init(&ctx->N);
    247.       bn_init(&ctx->Ni);

crypto/bn/bn_mont.c:246:5: Skipping bn_init(): empty list of specs
    244.       ctx->ri = 0;
    245.       bn_init(&ctx->RR);
    246.       bn_init(&ctx->N);
               ^
    247.       bn_init(&ctx->Ni);
    248.       ctx->n0[0] = ctx->n0[1] = 0;

crypto/bn/bn_mont.c:247:5: Skipping bn_init(): empty list of specs
    245.       bn_init(&ctx->RR);
    246.       bn_init(&ctx->N);
    247.       bn_init(&ctx->Ni);
               ^
    248.       ctx->n0[0] = ctx->n0[1] = 0;
    249.       ctx->flags = 0;

crypto/bn/bn_mont.c:248:5: 
    246.       bn_init(&ctx->N);
    247.       bn_init(&ctx->Ni);
    248. >     ctx->n0[0] = ctx->n0[1] = 0;
    249.       ctx->flags = 0;
    250.   }

crypto/bn/bn_mont.c:249:5: 
    247.       bn_init(&ctx->Ni);
    248.       ctx->n0[0] = ctx->n0[1] = 0;
    249. >     ctx->flags = 0;
    250.   }
    251.   

crypto/bn/bn_mont.c:250:1: return from a call to BN_MONT_CTX_init
    248.       ctx->n0[0] = ctx->n0[1] = 0;
    249.       ctx->flags = 0;
    250. > }
    251.   
    252.   void BN_MONT_CTX_free(BN_MONT_CTX *mont)

crypto/bn/bn_mont.c:238:5: 
  236.   
  237.       BN_MONT_CTX_init(ret);
  238. >     ret->flags = BN_FLG_MALLOCED;
  239.       return ret;
  240.   }

crypto/bn/bn_mont.c:239:5: 
  237.       BN_MONT_CTX_init(ret);
  238.       ret->flags = BN_FLG_MALLOCED;
  239. >     return ret;
  240.   }
  241.   

crypto/bn/bn_mont.c:240:1: return from a call to BN_MONT_CTX_new
  238.       ret->flags = BN_FLG_MALLOCED;
  239.       return ret;
  240. > }
  241.   
  242.   void BN_MONT_CTX_init(BN_MONT_CTX *ctx)

crypto/ec/ec_lib.c:1013:9: Taking false branch
1011.   
1012.       group->mont_data = BN_MONT_CTX_new();
1013.       if (group->mont_data == NULL)
                ^
1014.           goto err;
1015.   

crypto/ec/ec_lib.c:1016:10: Taking true branch
1014.           goto err;
1015.   
1016.       if (!BN_MONT_CTX_set(group->mont_data, group->order, ctx)) {
                 ^
1017.           BN_MONT_CTX_free(group->mont_data);
1018.           group->mont_data = NULL;

crypto/ec/ec_lib.c:1017:9: Skipping BN_MONT_CTX_free(): empty list of specs
1015.   
1016.       if (!BN_MONT_CTX_set(group->mont_data, group->order, ctx)) {
1017.           BN_MONT_CTX_free(group->mont_data);
                ^
1018.           group->mont_data = NULL;
1019.           goto err;

crypto/ec/ec_lib.c:1018:9: 
1016.       if (!BN_MONT_CTX_set(group->mont_data, group->order, ctx)) {
1017.           BN_MONT_CTX_free(group->mont_data);
1018. >         group->mont_data = NULL;
1019.           goto err;
1020.       }

static int ec_precompute_mont_data(EC_GROUP *group)
{
    BN_CTX *ctx = BN_CTX_new();
    int ret = 0;
    BN_MONT_CTX_free(group->mont_data);
    group->mont_data = NULL;
    if (ctx == NULL)
        goto err;
    group->mont_data = BN_MONT_CTX_new();
    if (group->mont_data == NULL)
        goto err;
    if (!BN_MONT_CTX_set(group->mont_data, group->order, ctx)) {
        BN_MONT_CTX_free(group->mont_data);
        group->mont_data = NULL;
        goto err;
    }
    ret = 1;
 err:
    BN_CTX_free(ctx);
    return ret;
}
['static int ec_precompute_mont_data(EC_GROUP *group)\n{\n    BN_CTX *ctx = BN_CTX_new();\n    int ret = 0;\n    BN_MONT_CTX_free(group->mont_data);\n    group->mont_data = NULL;\n    if (ctx == NULL)\n        goto err;\n    group->mont_data = BN_MONT_CTX_new();\n    if (group->mont_data == NULL)\n        goto err;\n    if (!BN_MONT_CTX_set(group->mont_data, group->order, ctx)) {\n        BN_MONT_CTX_free(group->mont_data);\n        group->mont_data = NULL;\n        goto err;\n    }\n    ret = 1;\n err:\n    BN_CTX_free(ctx);\n    return ret;\n}', 'BN_MONT_CTX *BN_MONT_CTX_new(void)\n{\n    BN_MONT_CTX *ret;\n    if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL) {\n        BNerr(BN_F_BN_MONT_CTX_NEW, ERR_R_MALLOC_FAILURE);\n        return NULL;\n    }\n    BN_MONT_CTX_init(ret);\n    ret->flags = BN_FLG_MALLOCED;\n    return ret;\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\n    INCREMENT(malloc_count);\n    if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)\n        return malloc_impl(num, file, line);\n    if (num == 0)\n        return NULL;\n    FAILTEST();\n    if (allow_customize) {\n        allow_customize = 0;\n    }\n#if !defined(OPENSSL_NO_CRYPTO_MDEBUG) && !defined(FIPS_MODE)\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); (void)(line);\n    ret = malloc(num);\n#endif\n    return ret;\n}', 'void BN_MONT_CTX_init(BN_MONT_CTX *ctx)\n{\n    ctx->ri = 0;\n    bn_init(&ctx->RR);\n    bn_init(&ctx->N);\n    bn_init(&ctx->Ni);\n    ctx->n0[0] = ctx->n0[1] = 0;\n    ctx->flags = 0;\n}']