test/evp_test.c:1609: error: MEMORY_LEAK
  memory dynamically allocated to `encode_ctx` by call to `EVP_ENCODE_CTX_new()` at line 1605, column 38 is not reachable after line 1609, column 13.
Showing all 56 steps of the trace


test/evp_test.c:1593:1: start of procedure encode_test_run()
1591.   }
1592.   
1593. > static int encode_test_run(struct evp_test *t)
1594.   {
1595.       struct encode_data *edata = t->data;

test/evp_test.c:1595:5: 
1593.   static int encode_test_run(struct evp_test *t)
1594.   {
1595. >     struct encode_data *edata = t->data;
1596.       unsigned char *encode_out = NULL, *decode_out = NULL;
1597.       int output_len, chunk_len;

test/evp_test.c:1596:5: 
1594.   {
1595.       struct encode_data *edata = t->data;
1596. >     unsigned char *encode_out = NULL, *decode_out = NULL;
1597.       int output_len, chunk_len;
1598.       const char *err = "INTERNAL_ERROR";

test/evp_test.c:1598:5: 
1596.       unsigned char *encode_out = NULL, *decode_out = NULL;
1597.       int output_len, chunk_len;
1598. >     const char *err = "INTERNAL_ERROR";
1599.       EVP_ENCODE_CTX *decode_ctx = EVP_ENCODE_CTX_new();
1600.   

test/evp_test.c:1599:5: 
1597.       int output_len, chunk_len;
1598.       const char *err = "INTERNAL_ERROR";
1599. >     EVP_ENCODE_CTX *decode_ctx = EVP_ENCODE_CTX_new();
1600.   
1601.       if (decode_ctx == NULL)

crypto/evp/encode.c:144:1: start of procedure EVP_ENCODE_CTX_new()
  142.   #endif
  143.   
  144. > EVP_ENCODE_CTX *EVP_ENCODE_CTX_new(void)
  145.   {
  146.       return (EVP_ENCODE_CTX *)OPENSSL_zalloc(sizeof(EVP_ENCODE_CTX));

crypto/evp/encode.c:146:5: 
  144.   EVP_ENCODE_CTX *EVP_ENCODE_CTX_new(void)
  145.   {
  146. >     return (EVP_ENCODE_CTX *)OPENSSL_zalloc(sizeof(EVP_ENCODE_CTX));
  147.   }
  148.   

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

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

crypto/mem.c:120:1: start of procedure CRYPTO_malloc()
      118.   }
      119.   
      120. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      121.   {
      122.       void *ret = NULL;

crypto/mem.c:122:5: 
      120.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      121.   {
      122. >     void *ret = NULL;
      123.   
      124.       if (num <= 0)

crypto/mem.c:124:9: Taking false branch
      122.       void *ret = NULL;
      123.   
      124.       if (num <= 0)
                     ^
      125.           return NULL;
      126.   

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

crypto/mem.c:137:5: 
      135.       }
      136.   #else
      137. >     (void)file;
      138.       (void)line;
      139.       ret = malloc(num);

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

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

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

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

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

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

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

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

crypto/evp/encode.c:147:1: return from a call to EVP_ENCODE_CTX_new
  145.   {
  146.       return (EVP_ENCODE_CTX *)OPENSSL_zalloc(sizeof(EVP_ENCODE_CTX));
  147. > }
  148.   
  149.   void EVP_ENCODE_CTX_free(EVP_ENCODE_CTX *ctx)

test/evp_test.c:1601:9: Taking false branch
1599.       EVP_ENCODE_CTX *decode_ctx = EVP_ENCODE_CTX_new();
1600.   
1601.       if (decode_ctx == NULL)
                ^
1602.           goto err;
1603.   

test/evp_test.c:1604:9: Taking true branch
1602.           goto err;
1603.   
1604.       if (edata->encoding == BASE64_CANONICAL_ENCODING) {
                ^
1605.           EVP_ENCODE_CTX *encode_ctx = EVP_ENCODE_CTX_new();
1606.           if (encode_ctx == NULL)

test/evp_test.c:1605:9: 
1603.   
1604.       if (edata->encoding == BASE64_CANONICAL_ENCODING) {
1605. >         EVP_ENCODE_CTX *encode_ctx = EVP_ENCODE_CTX_new();
1606.           if (encode_ctx == NULL)
1607.               goto err;

crypto/evp/encode.c:144:1: start of procedure EVP_ENCODE_CTX_new()
  142.   #endif
  143.   
  144. > EVP_ENCODE_CTX *EVP_ENCODE_CTX_new(void)
  145.   {
  146.       return (EVP_ENCODE_CTX *)OPENSSL_zalloc(sizeof(EVP_ENCODE_CTX));

crypto/evp/encode.c:146:5: 
  144.   EVP_ENCODE_CTX *EVP_ENCODE_CTX_new(void)
  145.   {
  146. >     return (EVP_ENCODE_CTX *)OPENSSL_zalloc(sizeof(EVP_ENCODE_CTX));
  147.   }
  148.   

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

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

crypto/mem.c:120:1: start of procedure CRYPTO_malloc()
      118.   }
      119.   
      120. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      121.   {
      122.       void *ret = NULL;

crypto/mem.c:122:5: 
      120.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      121.   {
      122. >     void *ret = NULL;
      123.   
      124.       if (num <= 0)

crypto/mem.c:124:9: Taking false branch
      122.       void *ret = NULL;
      123.   
      124.       if (num <= 0)
                     ^
      125.           return NULL;
      126.   

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

crypto/mem.c:137:5: 
      135.       }
      136.   #else
      137. >     (void)file;
      138.       (void)line;
      139.       ret = malloc(num);

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

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

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

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

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

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

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

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

crypto/evp/encode.c:147:1: return from a call to EVP_ENCODE_CTX_new
  145.   {
  146.       return (EVP_ENCODE_CTX *)OPENSSL_zalloc(sizeof(EVP_ENCODE_CTX));
  147. > }
  148.   
  149.   void EVP_ENCODE_CTX_free(EVP_ENCODE_CTX *ctx)

test/evp_test.c:1606:13: Taking false branch
1604.       if (edata->encoding == BASE64_CANONICAL_ENCODING) {
1605.           EVP_ENCODE_CTX *encode_ctx = EVP_ENCODE_CTX_new();
1606.           if (encode_ctx == NULL)
                    ^
1607.               goto err;
1608.           encode_out = OPENSSL_malloc(EVP_ENCODE_LENGTH(edata->input_len));

test/evp_test.c:1608:9: 
1606.           if (encode_ctx == NULL)
1607.               goto err;
1608. >         encode_out = OPENSSL_malloc(EVP_ENCODE_LENGTH(edata->input_len));
1609.           if (encode_out == NULL)
1610.               goto err;

crypto/mem.c:120:1: start of procedure CRYPTO_malloc()
  118.   }
  119.   
  120. > void *CRYPTO_malloc(size_t num, const char *file, int line)
  121.   {
  122.       void *ret = NULL;

crypto/mem.c:122:5: 
  120.   void *CRYPTO_malloc(size_t num, const char *file, int line)
  121.   {
  122. >     void *ret = NULL;
  123.   
  124.       if (num <= 0)

crypto/mem.c:124:9: Taking false branch
  122.       void *ret = NULL;
  123.   
  124.       if (num <= 0)
                 ^
  125.           return NULL;
  126.   

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

crypto/mem.c:137:5: 
  135.       }
  136.   #else
  137. >     (void)file;
  138.       (void)line;
  139.       ret = malloc(num);

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

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

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

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

test/evp_test.c:1609:13: Taking true branch
1607.               goto err;
1608.           encode_out = OPENSSL_malloc(EVP_ENCODE_LENGTH(edata->input_len));
1609.           if (encode_out == NULL)
                    ^
1610.               goto err;
1611.   

static int encode_test_run(struct evp_test *t)
{
    struct encode_data *edata = t->data;
    unsigned char *encode_out = NULL, *decode_out = NULL;
    int output_len, chunk_len;
    const char *err = "INTERNAL_ERROR";
    EVP_ENCODE_CTX *decode_ctx = EVP_ENCODE_CTX_new();
    if (decode_ctx == NULL)
        goto err;
    if (edata->encoding == BASE64_CANONICAL_ENCODING) {
        EVP_ENCODE_CTX *encode_ctx = EVP_ENCODE_CTX_new();
        if (encode_ctx == NULL)
            goto err;
        encode_out = OPENSSL_malloc(EVP_ENCODE_LENGTH(edata->input_len));
        if (encode_out == NULL)
            goto err;
        EVP_EncodeInit(encode_ctx);
        EVP_EncodeUpdate(encode_ctx, encode_out, &chunk_len,
                         edata->input, edata->input_len);
        output_len = chunk_len;
        EVP_EncodeFinal(encode_ctx, encode_out + chunk_len, &chunk_len);
        output_len += chunk_len;
        EVP_ENCODE_CTX_free(encode_ctx);
        if (check_var_length_output(t, edata->output, edata->output_len,
                                    encode_out, output_len)) {
            err = "BAD_ENCODING";
            goto err;
        }
    }
    decode_out = OPENSSL_malloc(EVP_DECODE_LENGTH(edata->output_len));
    if (decode_out == NULL)
        goto err;
    EVP_DecodeInit(decode_ctx);
    if (EVP_DecodeUpdate(decode_ctx, decode_out, &chunk_len, edata->output,
                         edata->output_len) < 0) {
        err = "DECODE_ERROR";
        goto err;
    }
    output_len = chunk_len;
    if (EVP_DecodeFinal(decode_ctx, decode_out + chunk_len, &chunk_len) != 1) {
        err = "DECODE_ERROR";
        goto err;
    }
    output_len += chunk_len;
    if (edata->encoding != BASE64_INVALID_ENCODING &&
        check_var_length_output(t, edata->input, edata->input_len,
                                decode_out, output_len)) {
        err = "BAD_DECODING";
        goto err;
    }
    err = NULL;
 err:
    t->err = err;
    OPENSSL_free(encode_out);
    OPENSSL_free(decode_out);
    EVP_ENCODE_CTX_free(decode_ctx);
    return 1;
}
['static int encode_test_run(struct evp_test *t)\n{\n    struct encode_data *edata = t->data;\n    unsigned char *encode_out = NULL, *decode_out = NULL;\n    int output_len, chunk_len;\n    const char *err = "INTERNAL_ERROR";\n    EVP_ENCODE_CTX *decode_ctx = EVP_ENCODE_CTX_new();\n    if (decode_ctx == NULL)\n        goto err;\n    if (edata->encoding == BASE64_CANONICAL_ENCODING) {\n        EVP_ENCODE_CTX *encode_ctx = EVP_ENCODE_CTX_new();\n        if (encode_ctx == NULL)\n            goto err;\n        encode_out = OPENSSL_malloc(EVP_ENCODE_LENGTH(edata->input_len));\n        if (encode_out == NULL)\n            goto err;\n        EVP_EncodeInit(encode_ctx);\n        EVP_EncodeUpdate(encode_ctx, encode_out, &chunk_len,\n                         edata->input, edata->input_len);\n        output_len = chunk_len;\n        EVP_EncodeFinal(encode_ctx, encode_out + chunk_len, &chunk_len);\n        output_len += chunk_len;\n        EVP_ENCODE_CTX_free(encode_ctx);\n        if (check_var_length_output(t, edata->output, edata->output_len,\n                                    encode_out, output_len)) {\n            err = "BAD_ENCODING";\n            goto err;\n        }\n    }\n    decode_out = OPENSSL_malloc(EVP_DECODE_LENGTH(edata->output_len));\n    if (decode_out == NULL)\n        goto err;\n    EVP_DecodeInit(decode_ctx);\n    if (EVP_DecodeUpdate(decode_ctx, decode_out, &chunk_len, edata->output,\n                         edata->output_len) < 0) {\n        err = "DECODE_ERROR";\n        goto err;\n    }\n    output_len = chunk_len;\n    if (EVP_DecodeFinal(decode_ctx, decode_out + chunk_len, &chunk_len) != 1) {\n        err = "DECODE_ERROR";\n        goto err;\n    }\n    output_len += chunk_len;\n    if (edata->encoding != BASE64_INVALID_ENCODING &&\n        check_var_length_output(t, edata->input, edata->input_len,\n                                decode_out, output_len)) {\n        err = "BAD_DECODING";\n        goto err;\n    }\n    err = NULL;\n err:\n    t->err = err;\n    OPENSSL_free(encode_out);\n    OPENSSL_free(decode_out);\n    EVP_ENCODE_CTX_free(decode_ctx);\n    return 1;\n}', 'EVP_ENCODE_CTX *EVP_ENCODE_CTX_new(void)\n{\n    return (EVP_ENCODE_CTX *)OPENSSL_zalloc(sizeof(EVP_ENCODE_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 (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}']