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


test/evp_test.c:1891:1: start of procedure encode_test_run()
1889.   }
1890.   
1891. > static int encode_test_run(struct evp_test *t)
1892.   {
1893.       struct encode_data *edata = t->data;

test/evp_test.c:1893:5: 
1891.   static int encode_test_run(struct evp_test *t)
1892.   {
1893. >     struct encode_data *edata = t->data;
1894.       unsigned char *encode_out = NULL, *decode_out = NULL;
1895.       int output_len, chunk_len;

test/evp_test.c:1894:5: 
1892.   {
1893.       struct encode_data *edata = t->data;
1894. >     unsigned char *encode_out = NULL, *decode_out = NULL;
1895.       int output_len, chunk_len;
1896.       const char *err = "INTERNAL_ERROR";

test/evp_test.c:1896:5: 
1894.       unsigned char *encode_out = NULL, *decode_out = NULL;
1895.       int output_len, chunk_len;
1896. >     const char *err = "INTERNAL_ERROR";
1897.       EVP_ENCODE_CTX *decode_ctx = EVP_ENCODE_CTX_new();
1898.   

test/evp_test.c:1897:5: 
1895.       int output_len, chunk_len;
1896.       const char *err = "INTERNAL_ERROR";
1897. >     EVP_ENCODE_CTX *decode_ctx = EVP_ENCODE_CTX_new();
1898.   
1899.       if (decode_ctx == NULL)

crypto/evp/encode.c:96:1: start of procedure EVP_ENCODE_CTX_new()
  94.   #endif
  95.   
  96. > EVP_ENCODE_CTX *EVP_ENCODE_CTX_new(void)
  97.   {
  98.       return OPENSSL_zalloc(sizeof(EVP_ENCODE_CTX));

crypto/evp/encode.c:98:5: 
  96.   EVP_ENCODE_CTX *EVP_ENCODE_CTX_new(void)
  97.   {
  98. >     return OPENSSL_zalloc(sizeof(EVP_ENCODE_CTX));
  99.   }
  100.   

crypto/mem.c:186:1: start of procedure CRYPTO_zalloc()
    184.   }
    185.   
    186. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    187.   {
    188.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:188:5: 
    186.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    187.   {
    188. >     void *ret = CRYPTO_malloc(num, file, line);
    189.   
    190.       FAILTEST();

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

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

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

crypto/mem.c:165:9: Taking false branch
      163.           return malloc_impl(num, file, line);
      164.   
      165.       if (num == 0)
                     ^
      166.           return NULL;
      167.   

crypto/mem.c:169:5: 
      167.   
      168.       FAILTEST();
      169. >     allow_customize = 0;
      170.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
      171.       if (call_malloc_debug) {

crypto/mem.c:179:5: 
      177.       }
      178.   #else
      179. >     osslargused(file); osslargused(line);
      180.       ret = malloc(num);
      181.   #endif

crypto/mem.c:179:24: 
      177.       }
      178.   #else
      179. >     osslargused(file); osslargused(line);
      180.       ret = malloc(num);
      181.   #endif

crypto/mem.c:180:5: 
      178.   #else
      179.       osslargused(file); osslargused(line);
      180. >     ret = malloc(num);
      181.   #endif
      182.   

crypto/mem.c:183:5: 
      181.   #endif
      182.   
      183. >     return ret;
      184.   }
      185.   

crypto/mem.c:184:1: return from a call to CRYPTO_malloc
      182.   
      183.       return ret;
      184. > }
      185.   
      186.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:191:9: Taking true branch
    189.   
    190.       FAILTEST();
    191.       if (ret != NULL)
                   ^
    192.           memset(ret, 0, num);
    193.       return ret;

crypto/mem.c:192:9: 
    190.       FAILTEST();
    191.       if (ret != NULL)
    192. >         memset(ret, 0, num);
    193.       return ret;
    194.   }

crypto/mem.c:193:5: 
    191.       if (ret != NULL)
    192.           memset(ret, 0, num);
    193. >     return ret;
    194.   }
    195.   

crypto/mem.c:194:1: return from a call to CRYPTO_zalloc
    192.           memset(ret, 0, num);
    193.       return ret;
    194. > }
    195.   
    196.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/evp/encode.c:99:1: return from a call to EVP_ENCODE_CTX_new
  97.   {
  98.       return OPENSSL_zalloc(sizeof(EVP_ENCODE_CTX));
  99. > }
  100.   
  101.   void EVP_ENCODE_CTX_free(EVP_ENCODE_CTX *ctx)

test/evp_test.c:1899:9: Taking false branch
1897.       EVP_ENCODE_CTX *decode_ctx = EVP_ENCODE_CTX_new();
1898.   
1899.       if (decode_ctx == NULL)
                ^
1900.           goto err;
1901.   

test/evp_test.c:1902:9: Taking true branch
1900.           goto err;
1901.   
1902.       if (edata->encoding == BASE64_CANONICAL_ENCODING) {
                ^
1903.           EVP_ENCODE_CTX *encode_ctx = EVP_ENCODE_CTX_new();
1904.           if (encode_ctx == NULL)

test/evp_test.c:1903:9: 
1901.   
1902.       if (edata->encoding == BASE64_CANONICAL_ENCODING) {
1903. >         EVP_ENCODE_CTX *encode_ctx = EVP_ENCODE_CTX_new();
1904.           if (encode_ctx == NULL)
1905.               goto err;

crypto/evp/encode.c:96:1: start of procedure EVP_ENCODE_CTX_new()
  94.   #endif
  95.   
  96. > EVP_ENCODE_CTX *EVP_ENCODE_CTX_new(void)
  97.   {
  98.       return OPENSSL_zalloc(sizeof(EVP_ENCODE_CTX));

crypto/evp/encode.c:98:5: 
  96.   EVP_ENCODE_CTX *EVP_ENCODE_CTX_new(void)
  97.   {
  98. >     return OPENSSL_zalloc(sizeof(EVP_ENCODE_CTX));
  99.   }
  100.   

crypto/mem.c:186:1: start of procedure CRYPTO_zalloc()
    184.   }
    185.   
    186. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    187.   {
    188.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:188:5: 
    186.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    187.   {
    188. >     void *ret = CRYPTO_malloc(num, file, line);
    189.   
    190.       FAILTEST();

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

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

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

crypto/mem.c:165:9: Taking false branch
      163.           return malloc_impl(num, file, line);
      164.   
      165.       if (num == 0)
                     ^
      166.           return NULL;
      167.   

crypto/mem.c:169:5: 
      167.   
      168.       FAILTEST();
      169. >     allow_customize = 0;
      170.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
      171.       if (call_malloc_debug) {

crypto/mem.c:179:5: 
      177.       }
      178.   #else
      179. >     osslargused(file); osslargused(line);
      180.       ret = malloc(num);
      181.   #endif

crypto/mem.c:179:24: 
      177.       }
      178.   #else
      179. >     osslargused(file); osslargused(line);
      180.       ret = malloc(num);
      181.   #endif

crypto/mem.c:180:5: 
      178.   #else
      179.       osslargused(file); osslargused(line);
      180. >     ret = malloc(num);
      181.   #endif
      182.   

crypto/mem.c:183:5: 
      181.   #endif
      182.   
      183. >     return ret;
      184.   }
      185.   

crypto/mem.c:184:1: return from a call to CRYPTO_malloc
      182.   
      183.       return ret;
      184. > }
      185.   
      186.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:191:9: Taking true branch
    189.   
    190.       FAILTEST();
    191.       if (ret != NULL)
                   ^
    192.           memset(ret, 0, num);
    193.       return ret;

crypto/mem.c:192:9: 
    190.       FAILTEST();
    191.       if (ret != NULL)
    192. >         memset(ret, 0, num);
    193.       return ret;
    194.   }

crypto/mem.c:193:5: 
    191.       if (ret != NULL)
    192.           memset(ret, 0, num);
    193. >     return ret;
    194.   }
    195.   

crypto/mem.c:194:1: return from a call to CRYPTO_zalloc
    192.           memset(ret, 0, num);
    193.       return ret;
    194. > }
    195.   
    196.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/evp/encode.c:99:1: return from a call to EVP_ENCODE_CTX_new
  97.   {
  98.       return OPENSSL_zalloc(sizeof(EVP_ENCODE_CTX));
  99. > }
  100.   
  101.   void EVP_ENCODE_CTX_free(EVP_ENCODE_CTX *ctx)

test/evp_test.c:1904:13: Taking false branch
1902.       if (edata->encoding == BASE64_CANONICAL_ENCODING) {
1903.           EVP_ENCODE_CTX *encode_ctx = EVP_ENCODE_CTX_new();
1904.           if (encode_ctx == NULL)
                    ^
1905.               goto err;
1906.           encode_out = OPENSSL_malloc(EVP_ENCODE_LENGTH(edata->input_len));

test/evp_test.c:1906:9: 
1904.           if (encode_ctx == NULL)
1905.               goto err;
1906. >         encode_out = OPENSSL_malloc(EVP_ENCODE_LENGTH(edata->input_len));
1907.           if (encode_out == NULL)
1908.               goto err;

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

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

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

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

crypto/mem.c:163:9: Skipping __function_pointer__(): unresolved function pointer
  161.   
  162.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
  163.           return malloc_impl(num, file, line);
                 ^
  164.   
  165.       if (num == 0)

crypto/mem.c:184:1: return from a call to CRYPTO_malloc
  182.   
  183.       return ret;
  184. > }
  185.   
  186.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

test/evp_test.c:1907:13: Taking true branch
1905.               goto err;
1906.           encode_out = OPENSSL_malloc(EVP_ENCODE_LENGTH(edata->input_len));
1907.           if (encode_out == NULL)
                    ^
1908.               goto err;
1909.   

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 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    FAILTEST();\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    FAILTEST();\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}']