crypto/srp/srp_lib.c:236: error: MEMORY_LEAK
  memory dynamically allocated by call to `EVP_MD_CTX_new()` at line 215, column 12 is not reachable after line 236, column 5.
Showing all 56 steps of the trace


crypto/srp/srp_lib.c:205:1: start of procedure SRP_Calc_x()
203.   }
204.   
205. > BIGNUM *SRP_Calc_x(BIGNUM *s, const char *user, const char *pass)
206.   {
207.       unsigned char dig[SHA_DIGEST_LENGTH];

crypto/srp/srp_lib.c:210:5: 
208.       EVP_MD_CTX *ctxt;
209.       unsigned char *cs;
210. >     BIGNUM *res = NULL;
211.   
212.       if ((s == NULL) || (user == NULL) || (pass == NULL))

crypto/srp/srp_lib.c:212:10: Taking false branch
210.       BIGNUM *res = NULL;
211.   
212.       if ((s == NULL) || (user == NULL) || (pass == NULL))
                ^
213.           return NULL;
214.   

crypto/srp/srp_lib.c:212:25: Taking false branch
210.       BIGNUM *res = NULL;
211.   
212.       if ((s == NULL) || (user == NULL) || (pass == NULL))
                               ^
213.           return NULL;
214.   

crypto/srp/srp_lib.c:212:43: Taking false branch
210.       BIGNUM *res = NULL;
211.   
212.       if ((s == NULL) || (user == NULL) || (pass == NULL))
                                                 ^
213.           return NULL;
214.   

crypto/srp/srp_lib.c:215:5: 
213.           return NULL;
214.   
215. >     ctxt = EVP_MD_CTX_new();
216.       if (ctxt == NULL)
217.           return NULL;

crypto/evp/digest.c:152:1: start of procedure EVP_MD_CTX_new()
  150.   }
  151.   
  152. > EVP_MD_CTX *EVP_MD_CTX_new(void)
  153.   {
  154.       return OPENSSL_zalloc(sizeof(EVP_MD_CTX));

crypto/evp/digest.c:154:5: 
  152.   EVP_MD_CTX *EVP_MD_CTX_new(void)
  153.   {
  154. >     return OPENSSL_zalloc(sizeof(EVP_MD_CTX));
  155.   }
  156.   

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

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

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 (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:123:9: Taking false branch
      121.       void *ret = NULL;
      122.   
      123.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                     ^
      124.           return malloc_impl(num, file, line);
      125.   

crypto/mem.c:126:9: Taking false branch
      124.           return malloc_impl(num, file, line);
      125.   
      126.       if (num <= 0)
                     ^
      127.           return NULL;
      128.   

crypto/mem.c:129:5: 
      127.           return NULL;
      128.   
      129. >     allow_customize = 0;
      130.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
      131.       if (call_malloc_debug) {

crypto/mem.c:139:5: 
      137.       }
      138.   #else
      139. >     osslargused(file); osslargused(line);
      140.       ret = malloc(num);
      141.   #endif

crypto/mem.c:139:24: 
      137.       }
      138.   #else
      139. >     osslargused(file); osslargused(line);
      140.       ret = malloc(num);
      141.   #endif

crypto/mem.c:140:5: 
      138.   #else
      139.       osslargused(file); osslargused(line);
      140. >     ret = malloc(num);
      141.   #endif
      142.   

crypto/mem.c:155:5: 
      153.   #endif
      154.   
      155. >     return ret;
      156.   }
      157.   

crypto/mem.c:156:1: return from a call to CRYPTO_malloc
      154.   
      155.       return ret;
      156. > }
      157.   
      158.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

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

crypto/mem.c:163:9: 
    161.   
    162.       if (ret != NULL)
    163. >         memset(ret, 0, num);
    164.       return ret;
    165.   }

crypto/mem.c:164:5: 
    162.       if (ret != NULL)
    163.           memset(ret, 0, num);
    164. >     return ret;
    165.   }
    166.   

crypto/mem.c:165:1: return from a call to CRYPTO_zalloc
    163.           memset(ret, 0, num);
    164.       return ret;
    165. > }
    166.   
    167.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/evp/digest.c:155:1: return from a call to EVP_MD_CTX_new
  153.   {
  154.       return OPENSSL_zalloc(sizeof(EVP_MD_CTX));
  155. > }
  156.   
  157.   void EVP_MD_CTX_free(EVP_MD_CTX *ctx)

crypto/srp/srp_lib.c:216:9: Taking false branch
214.   
215.       ctxt = EVP_MD_CTX_new();
216.       if (ctxt == NULL)
               ^
217.           return NULL;
218.       if ((cs = OPENSSL_malloc(BN_num_bytes(s))) == NULL)

crypto/srp/srp_lib.c:218:9: 
216.       if (ctxt == NULL)
217.           return NULL;
218. >     if ((cs = OPENSSL_malloc(BN_num_bytes(s))) == NULL)
219.           goto err;
220.   

crypto/bn/bn_lib.c:214:1: start of procedure BN_num_bits()
  212.   }
  213.   
  214. > int BN_num_bits(const BIGNUM *a)
  215.   {
  216.       int i = a->top - 1;

crypto/bn/bn_lib.c:216:5: 
  214.   int BN_num_bits(const BIGNUM *a)
  215.   {
  216. >     int i = a->top - 1;
  217.       bn_check_top(a);
  218.   

crypto/bn/bn_lib.c:219:9: 
  217.       bn_check_top(a);
  218.   
  219. >     if (BN_is_zero(a))
  220.           return 0;
  221.       return ((i * BN_BITS2) + BN_num_bits_word(a->d[i]));

crypto/bn/bn_lib.c:975:1: start of procedure BN_is_zero()
    973.   }
    974.   
    975. > int BN_is_zero(const BIGNUM *a)
    976.   {
    977.       return a->top == 0;

crypto/bn/bn_lib.c:977:12: Condition is false
    975.   int BN_is_zero(const BIGNUM *a)
    976.   {
    977.       return a->top == 0;
                      ^
    978.   }
    979.   

crypto/bn/bn_lib.c:977:5: 
    975.   int BN_is_zero(const BIGNUM *a)
    976.   {
    977. >     return a->top == 0;
    978.   }
    979.   

crypto/bn/bn_lib.c:978:1: return from a call to BN_is_zero
    976.   {
    977.       return a->top == 0;
    978. > }
    979.   
    980.   int BN_is_one(const BIGNUM *a)

crypto/bn/bn_lib.c:219:9: Taking false branch
  217.       bn_check_top(a);
  218.   
  219.       if (BN_is_zero(a))
                 ^
  220.           return 0;
  221.       return ((i * BN_BITS2) + BN_num_bits_word(a->d[i]));

crypto/bn/bn_lib.c:221:5: Skipping BN_num_bits_word(): empty list of specs
  219.       if (BN_is_zero(a))
  220.           return 0;
  221.       return ((i * BN_BITS2) + BN_num_bits_word(a->d[i]));
             ^
  222.   }
  223.   

crypto/bn/bn_lib.c:222:1: return from a call to BN_num_bits
  220.           return 0;
  221.       return ((i * BN_BITS2) + BN_num_bits_word(a->d[i]));
  222. > }
  223.   
  224.   static void bn_free_d(BIGNUM *a)

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 (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:123:9: Taking true branch
  121.       void *ret = NULL;
  122.   
  123.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                 ^
  124.           return malloc_impl(num, file, line);
  125.   

crypto/mem.c:123:32: Taking true branch
  121.       void *ret = NULL;
  122.   
  123.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                                        ^
  124.           return malloc_impl(num, file, line);
  125.   

crypto/mem.c:124:9: Skipping __function_pointer__(): unresolved function pointer
  122.   
  123.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
  124.           return malloc_impl(num, file, line);
                 ^
  125.   
  126.       if (num <= 0)

crypto/mem.c:156:1: return from a call to CRYPTO_malloc
  154.   
  155.       return ret;
  156. > }
  157.   
  158.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/srp/srp_lib.c:218:9: Taking true branch
216.       if (ctxt == NULL)
217.           return NULL;
218.       if ((cs = OPENSSL_malloc(BN_num_bytes(s))) == NULL)
               ^
219.           goto err;
220.   

crypto/srp/srp_lib.c:235:2: 
233.   
234.       res = BN_bin2bn(dig, sizeof(dig), NULL);
235. >  err:
236.       EVP_MD_CTX_free(ctxt);
237.       return res;

crypto/srp/srp_lib.c:236:5: 
234.       res = BN_bin2bn(dig, sizeof(dig), NULL);
235.    err:
236. >     EVP_MD_CTX_free(ctxt);
237.       return res;
238.   }

crypto/evp/digest.c:157:1: start of procedure EVP_MD_CTX_free()
  155.   }
  156.   
  157. > void EVP_MD_CTX_free(EVP_MD_CTX *ctx)
  158.   {
  159.       EVP_MD_CTX_reset(ctx);

crypto/evp/digest.c:159:5: Skipping EVP_MD_CTX_reset(): empty list of specs
  157.   void EVP_MD_CTX_free(EVP_MD_CTX *ctx)
  158.   {
  159.       EVP_MD_CTX_reset(ctx);
             ^
  160.       OPENSSL_free(ctx);
  161.   }

crypto/evp/digest.c:160:5: 
  158.   {
  159.       EVP_MD_CTX_reset(ctx);
  160. >     OPENSSL_free(ctx);
  161.   }
  162.   

crypto/mem.c:222:1: start of procedure CRYPTO_free()
    220.   }
    221.   
    222. > void CRYPTO_free(void *str, const char *file, int line)
    223.   {
    224.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:224:9: Taking true branch
    222.   void CRYPTO_free(void *str, const char *file, int line)
    223.   {
    224.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    225.           free_impl(str, file, line);
    226.           return;

crypto/mem.c:224:30: Taking true branch
    222.   void CRYPTO_free(void *str, const char *file, int line)
    223.   {
    224.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                                        ^
    225.           free_impl(str, file, line);
    226.           return;

crypto/mem.c:225:9: Skipping __function_pointer__(): unresolved function pointer
    223.   {
    224.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    225.           free_impl(str, file, line);
                   ^
    226.           return;
    227.       }

crypto/mem.c:226:9: 
    224.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    225.           free_impl(str, file, line);
    226. >         return;
    227.       }
    228.   

crypto/mem.c:240:1: return from a call to CRYPTO_free
    238.       free(str);
    239.   #endif
    240. > }
    241.   
    242.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

crypto/evp/digest.c:161:1: return from a call to EVP_MD_CTX_free
  159.       EVP_MD_CTX_reset(ctx);
  160.       OPENSSL_free(ctx);
  161. > }
  162.   
  163.   int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type)

BIGNUM *SRP_Calc_x(BIGNUM *s, const char *user, const char *pass)
{
    unsigned char dig[SHA_DIGEST_LENGTH];
    EVP_MD_CTX *ctxt;
    unsigned char *cs;
    BIGNUM *res = NULL;
    if ((s == NULL) || (user == NULL) || (pass == NULL))
        return NULL;
    ctxt = EVP_MD_CTX_new();
    if (ctxt == NULL)
        return NULL;
    if ((cs = OPENSSL_malloc(BN_num_bytes(s))) == NULL)
        goto err;
    EVP_DigestInit_ex(ctxt, EVP_sha1(), NULL);
    EVP_DigestUpdate(ctxt, user, strlen(user));
    EVP_DigestUpdate(ctxt, ":", 1);
    EVP_DigestUpdate(ctxt, pass, strlen(pass));
    EVP_DigestFinal_ex(ctxt, dig, NULL);
    EVP_DigestInit_ex(ctxt, EVP_sha1(), NULL);
    BN_bn2bin(s, cs);
    EVP_DigestUpdate(ctxt, cs, BN_num_bytes(s));
    OPENSSL_free(cs);
    EVP_DigestUpdate(ctxt, dig, sizeof(dig));
    EVP_DigestFinal_ex(ctxt, dig, NULL);
    res = BN_bin2bn(dig, sizeof(dig), NULL);
 err:
    EVP_MD_CTX_free(ctxt);
    return res;
}
['BIGNUM *SRP_Calc_x(BIGNUM *s, const char *user, const char *pass)\n{\n    unsigned char dig[SHA_DIGEST_LENGTH];\n    EVP_MD_CTX *ctxt;\n    unsigned char *cs;\n    BIGNUM *res = NULL;\n    if ((s == NULL) || (user == NULL) || (pass == NULL))\n        return NULL;\n    ctxt = EVP_MD_CTX_new();\n    if (ctxt == NULL)\n        return NULL;\n    if ((cs = OPENSSL_malloc(BN_num_bytes(s))) == NULL)\n        goto err;\n    EVP_DigestInit_ex(ctxt, EVP_sha1(), NULL);\n    EVP_DigestUpdate(ctxt, user, strlen(user));\n    EVP_DigestUpdate(ctxt, ":", 1);\n    EVP_DigestUpdate(ctxt, pass, strlen(pass));\n    EVP_DigestFinal_ex(ctxt, dig, NULL);\n    EVP_DigestInit_ex(ctxt, EVP_sha1(), NULL);\n    BN_bn2bin(s, cs);\n    EVP_DigestUpdate(ctxt, cs, BN_num_bytes(s));\n    OPENSSL_free(cs);\n    EVP_DigestUpdate(ctxt, dig, sizeof(dig));\n    EVP_DigestFinal_ex(ctxt, dig, NULL);\n    res = BN_bin2bn(dig, sizeof(dig), NULL);\n err:\n    EVP_MD_CTX_free(ctxt);\n    return res;\n}', 'EVP_MD_CTX *EVP_MD_CTX_new(void)\n{\n    return OPENSSL_zalloc(sizeof(EVP_MD_CTX));\n}', 'void *CRYPTO_zalloc(size_t num, const char *file, int line)\n{\n    void *ret = CRYPTO_malloc(num, file, line);\n    if (ret != NULL)\n        memset(ret, 0, num);\n    return ret;\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\n    if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)\n        return malloc_impl(num, file, line);\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    osslargused(file); osslargused(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}', 'int BN_num_bits(const BIGNUM *a)\n{\n    int i = a->top - 1;\n    bn_check_top(a);\n    if (BN_is_zero(a))\n        return 0;\n    return ((i * BN_BITS2) + BN_num_bits_word(a->d[i]));\n}', 'int BN_is_zero(const BIGNUM *a)\n{\n    return a->top == 0;\n}', 'void EVP_MD_CTX_free(EVP_MD_CTX *ctx)\n{\n    EVP_MD_CTX_reset(ctx);\n    OPENSSL_free(ctx);\n}', 'void CRYPTO_free(void *str, const char *file, int line)\n{\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}']