crypto/bn/bn_mpi.c:120: error: MEMORY_LEAK
  memory dynamically allocated to `return` by call to `BN_new()` at line 107, column 13 is not reachable after line 120, column 9.
Showing all 34 steps of the trace


crypto/bn/bn_mpi.c:90:1: start of procedure BN_mpi2bn()
88.   }
89.   
90. > BIGNUM *BN_mpi2bn(const unsigned char *d, int n, BIGNUM *a)
91.   {
92.       long len;

crypto/bn/bn_mpi.c:93:5: 
91.   {
92.       long len;
93. >     int neg = 0;
94.   
95.       if (n < 4) {

crypto/bn/bn_mpi.c:95:9: Taking false branch
93.       int neg = 0;
94.   
95.       if (n < 4) {
              ^
96.           BNerr(BN_F_BN_MPI2BN, BN_R_INVALID_LENGTH);
97.           return (NULL);

crypto/bn/bn_mpi.c:99:5: 
97.           return (NULL);
98.       }
99. >     len = ((long)d[0] << 24) | ((long)d[1] << 16) | ((int)d[2] << 8) | (int)
100.           d[3];
101.       if ((len + 4) != n) {

crypto/bn/bn_mpi.c:101:9: Taking false branch
99.       len = ((long)d[0] << 24) | ((long)d[1] << 16) | ((int)d[2] << 8) | (int)
100.           d[3];
101.       if ((len + 4) != n) {
               ^
102.           BNerr(BN_F_BN_MPI2BN, BN_R_ENCODING_ERROR);
103.           return (NULL);

crypto/bn/bn_mpi.c:106:9: Taking true branch
104.       }
105.   
106.       if (a == NULL)
               ^
107.           a = BN_new();
108.       if (a == NULL)

crypto/bn/bn_mpi.c:107:9: 
105.   
106.       if (a == NULL)
107. >         a = BN_new();
108.       if (a == NULL)
109.           return (NULL);

crypto/bn/bn_lib.c:276:1: start of procedure BN_new()
  274.   }
  275.   
  276. > BIGNUM *BN_new(void)
  277.   {
  278.       BIGNUM *ret;

crypto/bn/bn_lib.c:280:9: 
  278.       BIGNUM *ret;
  279.   
  280. >     if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) {
  281.           BNerr(BN_F_BN_NEW, ERR_R_MALLOC_FAILURE);
  282.           return (NULL);

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

crypto/mem.c:158:5: 
    156.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    157.   {
    158. >     void *ret = CRYPTO_malloc(num, file, line);
    159.   
    160.       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 (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/mem.c:160:9: Taking true branch
    158.       void *ret = CRYPTO_malloc(num, file, line);
    159.   
    160.       if (ret != NULL)
                   ^
    161.           memset(ret, 0, num);
    162.       return ret;

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

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

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

crypto/bn/bn_lib.c:280:9: Taking false branch
  278.       BIGNUM *ret;
  279.   
  280.       if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) {
                 ^
  281.           BNerr(BN_F_BN_NEW, ERR_R_MALLOC_FAILURE);
  282.           return (NULL);

crypto/bn/bn_lib.c:284:5: 
  282.           return (NULL);
  283.       }
  284. >     ret->flags = BN_FLG_MALLOCED;
  285.       bn_check_top(ret);
  286.       return (ret);

crypto/bn/bn_lib.c:286:5: 
  284.       ret->flags = BN_FLG_MALLOCED;
  285.       bn_check_top(ret);
  286. >     return (ret);
  287.   }
  288.   

crypto/bn/bn_lib.c:287:1: return from a call to BN_new
  285.       bn_check_top(ret);
  286.       return (ret);
  287. > }
  288.   
  289.    BIGNUM *BN_secure_new(void)

crypto/bn/bn_mpi.c:108:9: Taking false branch
106.       if (a == NULL)
107.           a = BN_new();
108.       if (a == NULL)
               ^
109.           return (NULL);
110.   

crypto/bn/bn_mpi.c:111:9: Taking false branch
109.           return (NULL);
110.   
111.       if (len == 0) {
               ^
112.           a->neg = 0;
113.           a->top = 0;

crypto/bn/bn_mpi.c:116:5: 
114.           return (a);
115.       }
116. >     d += 4;
117.       if ((*d) & 0x80)
118.           neg = 1;

crypto/bn/bn_mpi.c:117:9: Taking false branch
115.       }
116.       d += 4;
117.       if ((*d) & 0x80)
               ^
118.           neg = 1;
119.       if (BN_bin2bn(d, (int)len, a) == NULL)

crypto/bn/bn_mpi.c:119:9: Taking true branch
117.       if ((*d) & 0x80)
118.           neg = 1;
119.       if (BN_bin2bn(d, (int)len, a) == NULL)
               ^
120.           return (NULL);
121.       a->neg = neg;

crypto/bn/bn_mpi.c:120:9: 
118.           neg = 1;
119.       if (BN_bin2bn(d, (int)len, a) == NULL)
120. >         return (NULL);
121.       a->neg = neg;
122.       if (neg) {

BIGNUM *BN_mpi2bn(const unsigned char *d, int n, BIGNUM *a)
{
    long len;
    int neg = 0;
    if (n < 4) {
        BNerr(BN_F_BN_MPI2BN, BN_R_INVALID_LENGTH);
        return (NULL);
    }
    len = ((long)d[0] << 24) | ((long)d[1] << 16) | ((int)d[2] << 8) | (int)
        d[3];
    if ((len + 4) != n) {
        BNerr(BN_F_BN_MPI2BN, BN_R_ENCODING_ERROR);
        return (NULL);
    }
    if (a == NULL)
        a = BN_new();
    if (a == NULL)
        return (NULL);
    if (len == 0) {
        a->neg = 0;
        a->top = 0;
        return (a);
    }
    d += 4;
    if ((*d) & 0x80)
        neg = 1;
    if (BN_bin2bn(d, (int)len, a) == NULL)
        return (NULL);
    a->neg = neg;
    if (neg) {
        BN_clear_bit(a, BN_num_bits(a) - 1);
    }
    bn_check_top(a);
    return (a);
}
['BIGNUM *BN_mpi2bn(const unsigned char *d, int n, BIGNUM *a)\n{\n    long len;\n    int neg = 0;\n    if (n < 4) {\n        BNerr(BN_F_BN_MPI2BN, BN_R_INVALID_LENGTH);\n        return (NULL);\n    }\n    len = ((long)d[0] << 24) | ((long)d[1] << 16) | ((int)d[2] << 8) | (int)\n        d[3];\n    if ((len + 4) != n) {\n        BNerr(BN_F_BN_MPI2BN, BN_R_ENCODING_ERROR);\n        return (NULL);\n    }\n    if (a == NULL)\n        a = BN_new();\n    if (a == NULL)\n        return (NULL);\n    if (len == 0) {\n        a->neg = 0;\n        a->top = 0;\n        return (a);\n    }\n    d += 4;\n    if ((*d) & 0x80)\n        neg = 1;\n    if (BN_bin2bn(d, (int)len, a) == NULL)\n        return (NULL);\n    a->neg = neg;\n    if (neg) {\n        BN_clear_bit(a, BN_num_bits(a) - 1);\n    }\n    bn_check_top(a);\n    return (a);\n}', 'BIGNUM *BN_new(void)\n{\n    BIGNUM *ret;\n    if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) {\n        BNerr(BN_F_BN_NEW, ERR_R_MALLOC_FAILURE);\n        return (NULL);\n    }\n    ret->flags = BN_FLG_MALLOCED;\n    bn_check_top(ret);\n    return (ret);\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 (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}']