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


crypto/ec/ec_lib.c:966:1: start of procedure ec_precompute_mont_data()
964.    * returns one on success. On error it returns zero.
965.    */
966. > static int ec_precompute_mont_data(EC_GROUP *group)
967.   {
968.       BN_CTX *ctx = BN_CTX_new();

crypto/ec/ec_lib.c:968:5: Skipping BN_CTX_new(): empty list of specs
966.   static int ec_precompute_mont_data(EC_GROUP *group)
967.   {
968.       BN_CTX *ctx = BN_CTX_new();
           ^
969.       int ret = 0;
970.   

crypto/ec/ec_lib.c:969:5: 
967.   {
968.       BN_CTX *ctx = BN_CTX_new();
969. >     int ret = 0;
970.   
971.       BN_MONT_CTX_free(group->mont_data);

crypto/ec/ec_lib.c:971:5: 
969.       int ret = 0;
970.   
971. >     BN_MONT_CTX_free(group->mont_data);
972.       group->mont_data = NULL;
973.   

crypto/bn/bn_mont.c:218:1: start of procedure BN_MONT_CTX_free()
  216.   }
  217.   
  218. > void BN_MONT_CTX_free(BN_MONT_CTX *mont)
  219.   {
  220.       BN_clear_free(&(mont->RR));

crypto/bn/bn_mont.c:220:5: Skipping BN_clear_free(): empty list of specs
  218.   void BN_MONT_CTX_free(BN_MONT_CTX *mont)
  219.   {
  220.       BN_clear_free(&(mont->RR));
             ^
  221.       BN_clear_free(&(mont->N));
  222.       BN_clear_free(&(mont->Ni));

crypto/bn/bn_mont.c:221:5: Skipping BN_clear_free(): empty list of specs
  219.   {
  220.       BN_clear_free(&(mont->RR));
  221.       BN_clear_free(&(mont->N));
             ^
  222.       BN_clear_free(&(mont->Ni));
  223.       if (mont->flags & BN_FLG_MALLOCED)

crypto/bn/bn_mont.c:222:5: Skipping BN_clear_free(): empty list of specs
  220.       BN_clear_free(&(mont->RR));
  221.       BN_clear_free(&(mont->N));
  222.       BN_clear_free(&(mont->Ni));
             ^
  223.       if (mont->flags & BN_FLG_MALLOCED)
  224.           OPENSSL_free(mont);

crypto/bn/bn_mont.c:223:9: Taking true branch
  221.       BN_clear_free(&(mont->N));
  222.       BN_clear_free(&(mont->Ni));
  223.       if (mont->flags & BN_FLG_MALLOCED)
                 ^
  224.           OPENSSL_free(mont);
  225.   }

crypto/bn/bn_mont.c:224:9: 
  222.       BN_clear_free(&(mont->Ni));
  223.       if (mont->flags & BN_FLG_MALLOCED)
  224. >         OPENSSL_free(mont);
  225.   }
  226.   

crypto/mem.c:295:1: start of procedure CRYPTO_free()
    293.   }
    294.   
    295. > void CRYPTO_free(void *str, const char *file, int line)
    296.   {
    297.       INCREMENT(free_count);

crypto/mem.c:298:9: Taking false branch
    296.   {
    297.       INCREMENT(free_count);
    298.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    299.           free_impl(str, file, line);
    300.           return;

crypto/mem.c:312:5: 
    310.       }
    311.   #else
    312. >     free(str);
    313.   #endif
    314.   }

crypto/mem.c:314:1: return from a call to CRYPTO_free
    312.       free(str);
    313.   #endif
    314. > }
    315.   
    316.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

crypto/bn/bn_mont.c:223:5: 
  221.       BN_clear_free(&(mont->N));
  222.       BN_clear_free(&(mont->Ni));
  223. >     if (mont->flags & BN_FLG_MALLOCED)
  224.           OPENSSL_free(mont);
  225.   }

crypto/bn/bn_mont.c:225:1: return from a call to BN_MONT_CTX_free
  223.       if (mont->flags & BN_FLG_MALLOCED)
  224.           OPENSSL_free(mont);
  225. > }
  226.   
  227.   int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx)

crypto/ec/ec_lib.c:972:5: 
970.   
971.       BN_MONT_CTX_free(group->mont_data);
972. >     group->mont_data = NULL;
973.   
974.       if (ctx == NULL)

crypto/ec/ec_lib.c:974:9: Taking false branch
972.       group->mont_data = NULL;
973.   
974.       if (ctx == NULL)
               ^
975.           goto err;
976.   

crypto/ec/ec_lib.c:977:5: 
975.           goto err;
976.   
977. >     group->mont_data = BN_MONT_CTX_new();
978.       if (group->mont_data == NULL)
979.           goto err;

crypto/bn/bn_mont.c:196:1: start of procedure BN_MONT_CTX_new()
  194.   }
  195.   
  196. > BN_MONT_CTX *BN_MONT_CTX_new(void)
  197.   {
  198.       BN_MONT_CTX *ret;

crypto/bn/bn_mont.c:200:9: 
  198.       BN_MONT_CTX *ret;
  199.   
  200. >     if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL)
  201.           return NULL;
  202.   

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:200:9: Taking false branch
  198.       BN_MONT_CTX *ret;
  199.   
  200.       if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL)
                 ^
  201.           return NULL;
  202.   

crypto/bn/bn_mont.c:203:5: 
  201.           return NULL;
  202.   
  203. >     BN_MONT_CTX_init(ret);
  204.       ret->flags = BN_FLG_MALLOCED;
  205.       return ret;

crypto/bn/bn_mont.c:208:1: start of procedure BN_MONT_CTX_init()
    206.   }
    207.   
    208. > void BN_MONT_CTX_init(BN_MONT_CTX *ctx)
    209.   {
    210.       ctx->ri = 0;

crypto/bn/bn_mont.c:210:5: 
    208.   void BN_MONT_CTX_init(BN_MONT_CTX *ctx)
    209.   {
    210. >     ctx->ri = 0;
    211.       bn_init(&(ctx->RR));
    212.       bn_init(&(ctx->N));

crypto/bn/bn_mont.c:211:5: Skipping bn_init(): empty list of specs
    209.   {
    210.       ctx->ri = 0;
    211.       bn_init(&(ctx->RR));
               ^
    212.       bn_init(&(ctx->N));
    213.       bn_init(&(ctx->Ni));

crypto/bn/bn_mont.c:212:5: Skipping bn_init(): empty list of specs
    210.       ctx->ri = 0;
    211.       bn_init(&(ctx->RR));
    212.       bn_init(&(ctx->N));
               ^
    213.       bn_init(&(ctx->Ni));
    214.       ctx->n0[0] = ctx->n0[1] = 0;

crypto/bn/bn_mont.c:213:5: Skipping bn_init(): empty list of specs
    211.       bn_init(&(ctx->RR));
    212.       bn_init(&(ctx->N));
    213.       bn_init(&(ctx->Ni));
               ^
    214.       ctx->n0[0] = ctx->n0[1] = 0;
    215.       ctx->flags = 0;

crypto/bn/bn_mont.c:214:5: 
    212.       bn_init(&(ctx->N));
    213.       bn_init(&(ctx->Ni));
    214. >     ctx->n0[0] = ctx->n0[1] = 0;
    215.       ctx->flags = 0;
    216.   }

crypto/bn/bn_mont.c:215:5: 
    213.       bn_init(&(ctx->Ni));
    214.       ctx->n0[0] = ctx->n0[1] = 0;
    215. >     ctx->flags = 0;
    216.   }
    217.   

crypto/bn/bn_mont.c:216:1: return from a call to BN_MONT_CTX_init
    214.       ctx->n0[0] = ctx->n0[1] = 0;
    215.       ctx->flags = 0;
    216. > }
    217.   
    218.   void BN_MONT_CTX_free(BN_MONT_CTX *mont)

crypto/bn/bn_mont.c:204:5: 
  202.   
  203.       BN_MONT_CTX_init(ret);
  204. >     ret->flags = BN_FLG_MALLOCED;
  205.       return ret;
  206.   }

crypto/bn/bn_mont.c:205:5: 
  203.       BN_MONT_CTX_init(ret);
  204.       ret->flags = BN_FLG_MALLOCED;
  205. >     return ret;
  206.   }
  207.   

crypto/bn/bn_mont.c:206:1: return from a call to BN_MONT_CTX_new
  204.       ret->flags = BN_FLG_MALLOCED;
  205.       return ret;
  206. > }
  207.   
  208.   void BN_MONT_CTX_init(BN_MONT_CTX *ctx)

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

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

crypto/ec/ec_lib.c:982:9: 
980.   
981.       if (!BN_MONT_CTX_set(group->mont_data, group->order, ctx)) {
982. >         BN_MONT_CTX_free(group->mont_data);
983.           group->mont_data = NULL;
984.           goto err;

crypto/bn/bn_mont.c:218:1: start of procedure BN_MONT_CTX_free()
  216.   }
  217.   
  218. > void BN_MONT_CTX_free(BN_MONT_CTX *mont)
  219.   {
  220.       BN_clear_free(&(mont->RR));

crypto/bn/bn_mont.c:220:5: Skipping BN_clear_free(): empty list of specs
  218.   void BN_MONT_CTX_free(BN_MONT_CTX *mont)
  219.   {
  220.       BN_clear_free(&(mont->RR));
             ^
  221.       BN_clear_free(&(mont->N));
  222.       BN_clear_free(&(mont->Ni));

crypto/bn/bn_mont.c:221:5: Skipping BN_clear_free(): empty list of specs
  219.   {
  220.       BN_clear_free(&(mont->RR));
  221.       BN_clear_free(&(mont->N));
             ^
  222.       BN_clear_free(&(mont->Ni));
  223.       if (mont->flags & BN_FLG_MALLOCED)

crypto/bn/bn_mont.c:222:5: Skipping BN_clear_free(): empty list of specs
  220.       BN_clear_free(&(mont->RR));
  221.       BN_clear_free(&(mont->N));
  222.       BN_clear_free(&(mont->Ni));
             ^
  223.       if (mont->flags & BN_FLG_MALLOCED)
  224.           OPENSSL_free(mont);

crypto/bn/bn_mont.c:223:9: Taking false branch
  221.       BN_clear_free(&(mont->N));
  222.       BN_clear_free(&(mont->Ni));
  223.       if (mont->flags & BN_FLG_MALLOCED)
                 ^
  224.           OPENSSL_free(mont);
  225.   }

crypto/bn/bn_mont.c:223:5: 
  221.       BN_clear_free(&(mont->N));
  222.       BN_clear_free(&(mont->Ni));
  223. >     if (mont->flags & BN_FLG_MALLOCED)
  224.           OPENSSL_free(mont);
  225.   }

crypto/bn/bn_mont.c:225:1: return from a call to BN_MONT_CTX_free
  223.       if (mont->flags & BN_FLG_MALLOCED)
  224.           OPENSSL_free(mont);
  225. > }
  226.   
  227.   int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx)

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

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}', 'void BN_MONT_CTX_free(BN_MONT_CTX *mont)\n{\n    BN_clear_free(&(mont->RR));\n    BN_clear_free(&(mont->N));\n    BN_clear_free(&(mont->Ni));\n    if (mont->flags & BN_FLG_MALLOCED)\n        OPENSSL_free(mont);\n}', 'void CRYPTO_free(void *str, const char *file, int line)\n{\n    INCREMENT(free_count);\n    if (free_impl != NULL && free_impl != &CRYPTO_free) {\n        free_impl(str, file, line);\n        return;\n    }\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_free(str, 0, file, line);\n        free(str);\n        CRYPTO_mem_debug_free(str, 1, file, line);\n    } else {\n        free(str);\n    }\n#else\n    free(str);\n#endif\n}', 'BN_MONT_CTX *BN_MONT_CTX_new(void)\n{\n    BN_MONT_CTX *ret;\n    if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL)\n        return NULL;\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#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); (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}']