crypto/bn/bn_mont.c:522: error: MEMORY_LEAK
  memory dynamically allocated by call to `BN_MONT_CTX_new()` at line 518, column 11 is not reachable after line 522, column 9.
Showing all 45 steps of the trace


crypto/bn/bn_mont.c:499:1: start of procedure BN_MONT_CTX_set_locked()
497.   }
498.   
499. > BN_MONT_CTX *BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, int lock,
500.                                       const BIGNUM *mod, BN_CTX *ctx)
501.   {

crypto/bn/bn_mont.c:504:5: 
502.       BN_MONT_CTX *ret;
503.   
504. >     CRYPTO_r_lock(lock);
505.       ret = *pmont;
506.       CRYPTO_r_unlock(lock);

crypto/lock.c:413:1: start of procedure CRYPTO_lock()
  411.   }
  412.   
  413. > void CRYPTO_lock(int mode, int type, const char *file, int line)
  414.   {
  415.   #ifdef LOCK_DEBUG

crypto/lock.c:440:9: Taking false branch
  438.       }
  439.   #endif
  440.       if (type < 0) {
                 ^
  441.           if (dynlock_lock_callback != NULL) {
  442.               struct CRYPTO_dynlock_value *pointer

crypto/lock.c:451:16: Taking true branch
  449.               CRYPTO_destroy_dynlockid(type);
  450.           }
  451.       } else if (locking_callback != NULL)
                        ^
  452.           locking_callback(mode, type, file, line);
  453.   }

crypto/lock.c:452:9: Skipping __function_pointer__(): unresolved function pointer
  450.           }
  451.       } else if (locking_callback != NULL)
  452.           locking_callback(mode, type, file, line);
                 ^
  453.   }
  454.   

crypto/lock.c:440:5: 
  438.       }
  439.   #endif
  440. >     if (type < 0) {
  441.           if (dynlock_lock_callback != NULL) {
  442.               struct CRYPTO_dynlock_value *pointer

crypto/lock.c:453:1: return from a call to CRYPTO_lock
  451.       } else if (locking_callback != NULL)
  452.           locking_callback(mode, type, file, line);
  453. > }
  454.   
  455.   int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,

crypto/bn/bn_mont.c:505:5: 
503.   
504.       CRYPTO_r_lock(lock);
505. >     ret = *pmont;
506.       CRYPTO_r_unlock(lock);
507.       if (ret)

crypto/bn/bn_mont.c:506:5: 
504.       CRYPTO_r_lock(lock);
505.       ret = *pmont;
506. >     CRYPTO_r_unlock(lock);
507.       if (ret)
508.           return ret;

crypto/lock.c:413:1: start of procedure CRYPTO_lock()
  411.   }
  412.   
  413. > void CRYPTO_lock(int mode, int type, const char *file, int line)
  414.   {
  415.   #ifdef LOCK_DEBUG

crypto/lock.c:440:9: Taking false branch
  438.       }
  439.   #endif
  440.       if (type < 0) {
                 ^
  441.           if (dynlock_lock_callback != NULL) {
  442.               struct CRYPTO_dynlock_value *pointer

crypto/lock.c:451:16: Taking true branch
  449.               CRYPTO_destroy_dynlockid(type);
  450.           }
  451.       } else if (locking_callback != NULL)
                        ^
  452.           locking_callback(mode, type, file, line);
  453.   }

crypto/lock.c:452:9: Skipping __function_pointer__(): unresolved function pointer
  450.           }
  451.       } else if (locking_callback != NULL)
  452.           locking_callback(mode, type, file, line);
                 ^
  453.   }
  454.   

crypto/lock.c:440:5: 
  438.       }
  439.   #endif
  440. >     if (type < 0) {
  441.           if (dynlock_lock_callback != NULL) {
  442.               struct CRYPTO_dynlock_value *pointer

crypto/lock.c:453:1: return from a call to CRYPTO_lock
  451.       } else if (locking_callback != NULL)
  452.           locking_callback(mode, type, file, line);
  453. > }
  454.   
  455.   int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,

crypto/bn/bn_mont.c:507:9: Taking false branch
505.       ret = *pmont;
506.       CRYPTO_r_unlock(lock);
507.       if (ret)
               ^
508.           return ret;
509.   

crypto/bn/bn_mont.c:518:5: 
516.        * (the losers throw away the work they've done).
517.        */
518. >     ret = BN_MONT_CTX_new();
519.       if (ret == NULL)
520.           return NULL;

crypto/bn/bn_mont.c:314:1: start of procedure BN_MONT_CTX_new()
  312.   }
  313.   
  314. > BN_MONT_CTX *BN_MONT_CTX_new(void)
  315.   {
  316.       BN_MONT_CTX *ret;

crypto/bn/bn_mont.c:318:9: 
  316.       BN_MONT_CTX *ret;
  317.   
  318. >     if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL)
  319.           return (NULL);
  320.   

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/bn/bn_mont.c:318:9: Taking false branch
  316.       BN_MONT_CTX *ret;
  317.   
  318.       if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL)
                 ^
  319.           return (NULL);
  320.   

crypto/bn/bn_mont.c:321:5: 
  319.           return (NULL);
  320.   
  321. >     BN_MONT_CTX_init(ret);
  322.       ret->flags = BN_FLG_MALLOCED;
  323.       return (ret);

crypto/bn/bn_mont.c:326:1: start of procedure BN_MONT_CTX_init()
    324.   }
    325.   
    326. > void BN_MONT_CTX_init(BN_MONT_CTX *ctx)
    327.   {
    328.       ctx->ri = 0;

crypto/bn/bn_mont.c:328:5: 
    326.   void BN_MONT_CTX_init(BN_MONT_CTX *ctx)
    327.   {
    328. >     ctx->ri = 0;
    329.       bn_init(&(ctx->RR));
    330.       bn_init(&(ctx->N));

crypto/bn/bn_mont.c:329:5: Skipping bn_init(): empty list of specs
    327.   {
    328.       ctx->ri = 0;
    329.       bn_init(&(ctx->RR));
               ^
    330.       bn_init(&(ctx->N));
    331.       bn_init(&(ctx->Ni));

crypto/bn/bn_mont.c:330:5: Skipping bn_init(): empty list of specs
    328.       ctx->ri = 0;
    329.       bn_init(&(ctx->RR));
    330.       bn_init(&(ctx->N));
               ^
    331.       bn_init(&(ctx->Ni));
    332.       ctx->n0[0] = ctx->n0[1] = 0;

crypto/bn/bn_mont.c:331:5: Skipping bn_init(): empty list of specs
    329.       bn_init(&(ctx->RR));
    330.       bn_init(&(ctx->N));
    331.       bn_init(&(ctx->Ni));
               ^
    332.       ctx->n0[0] = ctx->n0[1] = 0;
    333.       ctx->flags = 0;

crypto/bn/bn_mont.c:332:5: 
    330.       bn_init(&(ctx->N));
    331.       bn_init(&(ctx->Ni));
    332. >     ctx->n0[0] = ctx->n0[1] = 0;
    333.       ctx->flags = 0;
    334.   }

crypto/bn/bn_mont.c:333:5: 
    331.       bn_init(&(ctx->Ni));
    332.       ctx->n0[0] = ctx->n0[1] = 0;
    333. >     ctx->flags = 0;
    334.   }
    335.   

crypto/bn/bn_mont.c:334:1: return from a call to BN_MONT_CTX_init
    332.       ctx->n0[0] = ctx->n0[1] = 0;
    333.       ctx->flags = 0;
    334. > }
    335.   
    336.   void BN_MONT_CTX_free(BN_MONT_CTX *mont)

crypto/bn/bn_mont.c:322:5: 
  320.   
  321.       BN_MONT_CTX_init(ret);
  322. >     ret->flags = BN_FLG_MALLOCED;
  323.       return (ret);
  324.   }

crypto/bn/bn_mont.c:323:5: 
  321.       BN_MONT_CTX_init(ret);
  322.       ret->flags = BN_FLG_MALLOCED;
  323. >     return (ret);
  324.   }
  325.   

crypto/bn/bn_mont.c:324:1: return from a call to BN_MONT_CTX_new
  322.       ret->flags = BN_FLG_MALLOCED;
  323.       return (ret);
  324. > }
  325.   
  326.   void BN_MONT_CTX_init(BN_MONT_CTX *ctx)

crypto/bn/bn_mont.c:519:9: Taking false branch
517.        */
518.       ret = BN_MONT_CTX_new();
519.       if (ret == NULL)
               ^
520.           return NULL;
521.       if (!BN_MONT_CTX_set(ret, mod, ctx)) {

crypto/bn/bn_mont.c:521:10: Taking true branch
519.       if (ret == NULL)
520.           return NULL;
521.       if (!BN_MONT_CTX_set(ret, mod, ctx)) {
                ^
522.           BN_MONT_CTX_free(ret);
523.           return NULL;

crypto/bn/bn_mont.c:522:9: Skipping BN_MONT_CTX_free(): empty list of specs
520.           return NULL;
521.       if (!BN_MONT_CTX_set(ret, mod, ctx)) {
522.           BN_MONT_CTX_free(ret);
               ^
523.           return NULL;
524.       }

BN_MONT_CTX *BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, int lock,
                                    const BIGNUM *mod, BN_CTX *ctx)
{
    BN_MONT_CTX *ret;
    CRYPTO_r_lock(lock);
    ret = *pmont;
    CRYPTO_r_unlock(lock);
    if (ret)
        return ret;
    ret = BN_MONT_CTX_new();
    if (ret == NULL)
        return NULL;
    if (!BN_MONT_CTX_set(ret, mod, ctx)) {
        BN_MONT_CTX_free(ret);
        return NULL;
    }
    CRYPTO_w_lock(lock);
    if (*pmont) {
        BN_MONT_CTX_free(ret);
        ret = *pmont;
    } else
        *pmont = ret;
    CRYPTO_w_unlock(lock);
    return ret;
}
['BN_MONT_CTX *BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, int lock,\n                                    const BIGNUM *mod, BN_CTX *ctx)\n{\n    BN_MONT_CTX *ret;\n    CRYPTO_r_lock(lock);\n    ret = *pmont;\n    CRYPTO_r_unlock(lock);\n    if (ret)\n        return ret;\n    ret = BN_MONT_CTX_new();\n    if (ret == NULL)\n        return NULL;\n    if (!BN_MONT_CTX_set(ret, mod, ctx)) {\n        BN_MONT_CTX_free(ret);\n        return NULL;\n    }\n    CRYPTO_w_lock(lock);\n    if (*pmont) {\n        BN_MONT_CTX_free(ret);\n        ret = *pmont;\n    } else\n        *pmont = ret;\n    CRYPTO_w_unlock(lock);\n    return ret;\n}', 'void CRYPTO_lock(int mode, int type, const char *file, int line)\n{\n#ifdef LOCK_DEBUG\n    {\n        CRYPTO_THREADID id;\n        char *rw_text, *operation_text;\n        if (mode & CRYPTO_LOCK)\n            operation_text = "lock  ";\n        else if (mode & CRYPTO_UNLOCK)\n            operation_text = "unlock";\n        else\n            operation_text = "ERROR ";\n        if (mode & CRYPTO_READ)\n            rw_text = "r";\n        else if (mode & CRYPTO_WRITE)\n            rw_text = "w";\n        else\n            rw_text = "ERROR";\n        CRYPTO_THREADID_current(&id);\n        fprintf(stderr, "lock:%08lx:(%s)%s %-18s %s:%d\\n",\n                CRYPTO_THREADID_hash(&id), rw_text, operation_text,\n                CRYPTO_get_lock_name(type), file, line);\n    }\n#endif\n    if (type < 0) {\n        if (dynlock_lock_callback != NULL) {\n            struct CRYPTO_dynlock_value *pointer\n                = CRYPTO_get_dynlock_value(type);\n            OPENSSL_assert(pointer != NULL);\n            dynlock_lock_callback(mode, pointer, file, line);\n            CRYPTO_destroy_dynlockid(type);\n        }\n    } else if (locking_callback != NULL)\n        locking_callback(mode, type, file, line);\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    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}', '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}']