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


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

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

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

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

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

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

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

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/evp/encode.c:146:1: return from a call to EVP_ENCODE_CTX_new
  144.   {
  145.       return (EVP_ENCODE_CTX *)OPENSSL_zalloc(sizeof(EVP_ENCODE_CTX));
  146. > }
  147.   
  148.   void EVP_ENCODE_CTX_free(EVP_ENCODE_CTX *ctx)

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

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

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

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

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

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/evp/encode.c:146:1: return from a call to EVP_ENCODE_CTX_new
  144.   {
  145.       return (EVP_ENCODE_CTX *)OPENSSL_zalloc(sizeof(EVP_ENCODE_CTX));
  146. > }
  147.   
  148.   void EVP_ENCODE_CTX_free(EVP_ENCODE_CTX *ctx)

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

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

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)

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

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}']