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


crypto/srp/srp_lib.c:159:1: start of procedure SRP_Calc_x()
157.   }
158.   
159. > BIGNUM *SRP_Calc_x(BIGNUM *s, const char *user, const char *pass)
160.   {
161.       unsigned char dig[SHA_DIGEST_LENGTH];

crypto/srp/srp_lib.c:164:5: 
162.       EVP_MD_CTX *ctxt;
163.       unsigned char *cs;
164. >     BIGNUM *res = NULL;
165.   
166.       if ((s == NULL) || (user == NULL) || (pass == NULL))

crypto/srp/srp_lib.c:166:10: Taking false branch
164.       BIGNUM *res = NULL;
165.   
166.       if ((s == NULL) || (user == NULL) || (pass == NULL))
                ^
167.           return NULL;
168.   

crypto/srp/srp_lib.c:166:25: Taking false branch
164.       BIGNUM *res = NULL;
165.   
166.       if ((s == NULL) || (user == NULL) || (pass == NULL))
                               ^
167.           return NULL;
168.   

crypto/srp/srp_lib.c:166:43: Taking false branch
164.       BIGNUM *res = NULL;
165.   
166.       if ((s == NULL) || (user == NULL) || (pass == NULL))
                                                 ^
167.           return NULL;
168.   

crypto/srp/srp_lib.c:169:5: 
167.           return NULL;
168.   
169. >     ctxt = EVP_MD_CTX_new();
170.       if (ctxt == NULL)
171.           return NULL;

crypto/evp/digest.c:44:1: start of procedure EVP_MD_CTX_new()
  42.   }
  43.   
  44. > EVP_MD_CTX *EVP_MD_CTX_new(void)
  45.   {
  46.       return OPENSSL_zalloc(sizeof(EVP_MD_CTX));

crypto/evp/digest.c:46:5: 
  44.   EVP_MD_CTX *EVP_MD_CTX_new(void)
  45.   {
  46. >     return OPENSSL_zalloc(sizeof(EVP_MD_CTX));
  47.   }
  48.   

crypto/mem.c:98:1: start of procedure CRYPTO_zalloc()
    96.   }
    97.   
    98. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    99.   {
    100.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:100:5: 
    98.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    99.   {
    100. >     void *ret = CRYPTO_malloc(num, file, line);
    101.   
    102.       if (ret != NULL)

crypto/mem.c:71:1: start of procedure CRYPTO_malloc()
      69.   }
      70.   
      71. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      72.   {
      73.       void *ret = NULL;

crypto/mem.c:73:5: 
      71.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      72.   {
      73. >     void *ret = NULL;
      74.   
      75.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:75:9: Taking false branch
      73.       void *ret = NULL;
      74.   
      75.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                    ^
      76.           return malloc_impl(num, file, line);
      77.   

crypto/mem.c:78:9: Taking false branch
      76.           return malloc_impl(num, file, line);
      77.   
      78.       if (num <= 0)
                    ^
      79.           return NULL;
      80.   

crypto/mem.c:81:5: 
      79.           return NULL;
      80.   
      81. >     allow_customize = 0;
      82.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
      83.       if (call_malloc_debug) {

crypto/mem.c:91:5: 
      89.       }
      90.   #else
      91. >     osslargused(file); osslargused(line);
      92.       ret = malloc(num);
      93.   #endif

crypto/mem.c:91:24: 
      89.       }
      90.   #else
      91. >     osslargused(file); osslargused(line);
      92.       ret = malloc(num);
      93.   #endif

crypto/mem.c:92:5: 
      90.   #else
      91.       osslargused(file); osslargused(line);
      92. >     ret = malloc(num);
      93.   #endif
      94.   

crypto/mem.c:95:5: 
      93.   #endif
      94.   
      95. >     return ret;
      96.   }
      97.   

crypto/mem.c:96:1: return from a call to CRYPTO_malloc
      94.   
      95.       return ret;
      96. > }
      97.   
      98.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:102:9: Taking true branch
    100.       void *ret = CRYPTO_malloc(num, file, line);
    101.   
    102.       if (ret != NULL)
                   ^
    103.           memset(ret, 0, num);
    104.       return ret;

crypto/mem.c:103:9: 
    101.   
    102.       if (ret != NULL)
    103. >         memset(ret, 0, num);
    104.       return ret;
    105.   }

crypto/mem.c:104:5: 
    102.       if (ret != NULL)
    103.           memset(ret, 0, num);
    104. >     return ret;
    105.   }
    106.   

crypto/mem.c:105:1: return from a call to CRYPTO_zalloc
    103.           memset(ret, 0, num);
    104.       return ret;
    105. > }
    106.   
    107.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/evp/digest.c:47:1: return from a call to EVP_MD_CTX_new
  45.   {
  46.       return OPENSSL_zalloc(sizeof(EVP_MD_CTX));
  47. > }
  48.   
  49.   void EVP_MD_CTX_free(EVP_MD_CTX *ctx)

crypto/srp/srp_lib.c:170:9: Taking false branch
168.   
169.       ctxt = EVP_MD_CTX_new();
170.       if (ctxt == NULL)
               ^
171.           return NULL;
172.       if ((cs = OPENSSL_malloc(BN_num_bytes(s))) == NULL)

crypto/srp/srp_lib.c:172:9: 
170.       if (ctxt == NULL)
171.           return NULL;
172. >     if ((cs = OPENSSL_malloc(BN_num_bytes(s))) == NULL)
173.           goto err;
174.   

crypto/bn/bn_lib.c:161:1: start of procedure BN_num_bits()
  159.   }
  160.   
  161. > int BN_num_bits(const BIGNUM *a)
  162.   {
  163.       int i = a->top - 1;

crypto/bn/bn_lib.c:163:5: 
  161.   int BN_num_bits(const BIGNUM *a)
  162.   {
  163. >     int i = a->top - 1;
  164.       bn_check_top(a);
  165.   

crypto/bn/bn_lib.c:166:9: 
  164.       bn_check_top(a);
  165.   
  166. >     if (BN_is_zero(a))
  167.           return 0;
  168.       return ((i * BN_BITS2) + BN_num_bits_word(a->d[i]));

crypto/bn/bn_lib.c:918:1: start of procedure BN_is_zero()
    916.   }
    917.   
    918. > int BN_is_zero(const BIGNUM *a)
    919.   {
    920.       return a->top == 0;

crypto/bn/bn_lib.c:920:12: Condition is false
    918.   int BN_is_zero(const BIGNUM *a)
    919.   {
    920.       return a->top == 0;
                      ^
    921.   }
    922.   

crypto/bn/bn_lib.c:920:5: 
    918.   int BN_is_zero(const BIGNUM *a)
    919.   {
    920. >     return a->top == 0;
    921.   }
    922.   

crypto/bn/bn_lib.c:921:1: return from a call to BN_is_zero
    919.   {
    920.       return a->top == 0;
    921. > }
    922.   
    923.   int BN_is_one(const BIGNUM *a)

crypto/bn/bn_lib.c:166:9: Taking false branch
  164.       bn_check_top(a);
  165.   
  166.       if (BN_is_zero(a))
                 ^
  167.           return 0;
  168.       return ((i * BN_BITS2) + BN_num_bits_word(a->d[i]));

crypto/bn/bn_lib.c:168:5: Skipping BN_num_bits_word(): empty list of specs
  166.       if (BN_is_zero(a))
  167.           return 0;
  168.       return ((i * BN_BITS2) + BN_num_bits_word(a->d[i]));
             ^
  169.   }
  170.   

crypto/bn/bn_lib.c:169:1: return from a call to BN_num_bits
  167.           return 0;
  168.       return ((i * BN_BITS2) + BN_num_bits_word(a->d[i]));
  169. > }
  170.   
  171.   static void bn_free_d(BIGNUM *a)

crypto/mem.c:71:1: start of procedure CRYPTO_malloc()
  69.   }
  70.   
  71. > void *CRYPTO_malloc(size_t num, const char *file, int line)
  72.   {
  73.       void *ret = NULL;

crypto/mem.c:73:5: 
  71.   void *CRYPTO_malloc(size_t num, const char *file, int line)
  72.   {
  73. >     void *ret = NULL;
  74.   
  75.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:75:9: Taking true branch
  73.       void *ret = NULL;
  74.   
  75.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                ^
  76.           return malloc_impl(num, file, line);
  77.   

crypto/mem.c:75:32: Taking true branch
  73.       void *ret = NULL;
  74.   
  75.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                                       ^
  76.           return malloc_impl(num, file, line);
  77.   

crypto/mem.c:76:9: Skipping __function_pointer__(): unresolved function pointer
  74.   
  75.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
  76.           return malloc_impl(num, file, line);
                ^
  77.   
  78.       if (num <= 0)

crypto/mem.c:96:1: return from a call to CRYPTO_malloc
  94.   
  95.       return ret;
  96. > }
  97.   
  98.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/srp/srp_lib.c:172:9: Taking true branch
170.       if (ctxt == NULL)
171.           return NULL;
172.       if ((cs = OPENSSL_malloc(BN_num_bytes(s))) == NULL)
               ^
173.           goto err;
174.   

crypto/srp/srp_lib.c:189:2: 
187.   
188.       res = BN_bin2bn(dig, sizeof(dig), NULL);
189. >  err:
190.       EVP_MD_CTX_free(ctxt);
191.       return res;

crypto/srp/srp_lib.c:190:5: 
188.       res = BN_bin2bn(dig, sizeof(dig), NULL);
189.    err:
190. >     EVP_MD_CTX_free(ctxt);
191.       return res;
192.   }

crypto/evp/digest.c:49:1: start of procedure EVP_MD_CTX_free()
  47.   }
  48.   
  49. > void EVP_MD_CTX_free(EVP_MD_CTX *ctx)
  50.   {
  51.       EVP_MD_CTX_reset(ctx);

crypto/evp/digest.c:51:5: Skipping EVP_MD_CTX_reset(): empty list of specs
  49.   void EVP_MD_CTX_free(EVP_MD_CTX *ctx)
  50.   {
  51.       EVP_MD_CTX_reset(ctx);
            ^
  52.       OPENSSL_free(ctx);
  53.   }

crypto/evp/digest.c:52:5: 
  50.   {
  51.       EVP_MD_CTX_reset(ctx);
  52. >     OPENSSL_free(ctx);
  53.   }
  54.   

crypto/mem.c:163:1: start of procedure CRYPTO_free()
    161.   }
    162.   
    163. > void CRYPTO_free(void *str, const char *file, int line)
    164.   {
    165.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:165:9: Taking true branch
    163.   void CRYPTO_free(void *str, const char *file, int line)
    164.   {
    165.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    166.           free_impl(str, file, line);
    167.           return;

crypto/mem.c:165:30: Taking true branch
    163.   void CRYPTO_free(void *str, const char *file, int line)
    164.   {
    165.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                                        ^
    166.           free_impl(str, file, line);
    167.           return;

crypto/mem.c:166:9: Skipping __function_pointer__(): unresolved function pointer
    164.   {
    165.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    166.           free_impl(str, file, line);
                   ^
    167.           return;
    168.       }

crypto/mem.c:167:9: 
    165.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    166.           free_impl(str, file, line);
    167. >         return;
    168.       }
    169.   

crypto/mem.c:181:1: return from a call to CRYPTO_free
    179.       free(str);
    180.   #endif
    181. > }
    182.   
    183.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

crypto/evp/digest.c:53:1: return from a call to EVP_MD_CTX_free
  51.       EVP_MD_CTX_reset(ctx);
  52.       OPENSSL_free(ctx);
  53. > }
  54.   
  55.   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    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}']