test/mdc2test.c:67: error: MEMORY_LEAK
  memory dynamically allocated by call to `EVP_MD_CTX_new()` at line 49, column 9 is not reachable after line 67, column 5.
Showing all 53 steps of the trace


test/mdc2test.c:37:1: start of procedure test_mdc2()
35.   };
36.   
37. > static int test_mdc2(void)
38.   {
39.       int testresult = 0;

test/mdc2test.c:39:5: 
37.   static int test_mdc2(void)
38.   {
39. >     int testresult = 0;
40.       unsigned char md[MDC2_DIGEST_LENGTH];
41.       EVP_MD_CTX *c;

test/mdc2test.c:42:5: 
40.       unsigned char md[MDC2_DIGEST_LENGTH];
41.       EVP_MD_CTX *c;
42. >     static char text[] = "Now is the time for all ";
43.       size_t tlen = strlen(text);
44.   

test/mdc2test.c:43:5: 
41.       EVP_MD_CTX *c;
42.       static char text[] = "Now is the time for all ";
43. >     size_t tlen = strlen(text);
44.   
45.   # ifdef CHARSET_EBCDIC

test/mdc2test.c:49:5: 
47.   # endif
48.   
49. >     c = EVP_MD_CTX_new();
50.       if (!TEST_ptr(c)
51.           || !TEST_true(EVP_DigestInit_ex(c, EVP_mdc2(), 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:218:1: start of procedure CRYPTO_zalloc()
    216.   }
    217.   
    218. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    219.   {
    220.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:220:5: 
    218.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    219.   {
    220. >     void *ret = CRYPTO_malloc(num, file, line);
    221.   
    222.       FAILTEST();

crypto/mem.c:189:1: start of procedure CRYPTO_malloc()
      187.   #endif
      188.   
      189. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      190.   {
      191.       void *ret = NULL;

crypto/mem.c:191:5: 
      189.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      190.   {
      191. >     void *ret = NULL;
      192.   
      193.       INCREMENT(malloc_count);

crypto/mem.c:194:9: Taking false branch
      192.   
      193.       INCREMENT(malloc_count);
      194.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                     ^
      195.           return malloc_impl(num, file, line);
      196.   

crypto/mem.c:197:9: Taking false branch
      195.           return malloc_impl(num, file, line);
      196.   
      197.       if (num == 0)
                     ^
      198.           return NULL;
      199.   

crypto/mem.c:201:5: 
      199.   
      200.       FAILTEST();
      201. >     allow_customize = 0;
      202.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
      203.       if (call_malloc_debug) {

crypto/mem.c:211:5: 
      209.       }
      210.   #else
      211. >     (void)(file); (void)(line);
      212.       ret = malloc(num);
      213.   #endif

crypto/mem.c:211:19: 
      209.       }
      210.   #else
      211. >     (void)(file); (void)(line);
      212.       ret = malloc(num);
      213.   #endif

crypto/mem.c:212:5: 
      210.   #else
      211.       (void)(file); (void)(line);
      212. >     ret = malloc(num);
      213.   #endif
      214.   

crypto/mem.c:215:5: 
      213.   #endif
      214.   
      215. >     return ret;
      216.   }
      217.   

crypto/mem.c:216:1: return from a call to CRYPTO_malloc
      214.   
      215.       return ret;
      216. > }
      217.   
      218.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:223:9: Taking true branch
    221.   
    222.       FAILTEST();
    223.       if (ret != NULL)
                   ^
    224.           memset(ret, 0, num);
    225.       return ret;

crypto/mem.c:224:9: 
    222.       FAILTEST();
    223.       if (ret != NULL)
    224. >         memset(ret, 0, num);
    225.       return ret;
    226.   }

crypto/mem.c:225:5: 
    223.       if (ret != NULL)
    224.           memset(ret, 0, num);
    225. >     return ret;
    226.   }
    227.   

crypto/mem.c:226:1: return from a call to CRYPTO_zalloc
    224.           memset(ret, 0, num);
    225.       return ret;
    226. > }
    227.   
    228.   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)

test/mdc2test.c:50:10: 
48.   
49.       c = EVP_MD_CTX_new();
50. >     if (!TEST_ptr(c)
51.           || !TEST_true(EVP_DigestInit_ex(c, EVP_mdc2(), NULL))
52.           || !TEST_true(EVP_DigestUpdate(c, (unsigned char *)text, tlen))

test/testutil/tests.c:227:1: start of procedure test_ptr()
  225.   }
  226.   
  227. > int test_ptr(const char *file, int line, const char *s, const void *p)
  228.   {
  229.       if (p != NULL)

test/testutil/tests.c:229:9: Taking true branch
  227.   int test_ptr(const char *file, int line, const char *s, const void *p)
  228.   {
  229.       if (p != NULL)
                 ^
  230.           return 1;
  231.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);

test/testutil/tests.c:230:9: 
  228.   {
  229.       if (p != NULL)
  230. >         return 1;
  231.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  232.       return 0;

test/testutil/tests.c:233:1: return from a call to test_ptr
  231.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  232.       return 0;
  233. > }
  234.   
  235.   int test_true(const char *file, int line, const char *s, int b)

test/mdc2test.c:50:10: Taking false branch
48.   
49.       c = EVP_MD_CTX_new();
50.       if (!TEST_ptr(c)
               ^
51.           || !TEST_true(EVP_DigestInit_ex(c, EVP_mdc2(), NULL))
52.           || !TEST_true(EVP_DigestUpdate(c, (unsigned char *)text, tlen))

test/mdc2test.c:51:13: 
49.       c = EVP_MD_CTX_new();
50.       if (!TEST_ptr(c)
51. >         || !TEST_true(EVP_DigestInit_ex(c, EVP_mdc2(), NULL))
52.           || !TEST_true(EVP_DigestUpdate(c, (unsigned char *)text, tlen))
53.           || !TEST_true(EVP_DigestFinal_ex(c, &(md[0]), NULL))

crypto/evp/m_mdc2.c:51:1: start of procedure EVP_mdc2()
  49.   };
  50.   
  51. > const EVP_MD *EVP_mdc2(void)
  52.   {
  53.       return &mdc2_md;

crypto/evp/m_mdc2.c:53:5: 
  51.   const EVP_MD *EVP_mdc2(void)
  52.   {
  53. >     return &mdc2_md;
  54.   }
  55.   #endif

crypto/evp/m_mdc2.c:54:1: return from a call to EVP_mdc2
  52.   {
  53.       return &mdc2_md;
  54. > }
  55.   #endif

test/mdc2test.c:51:13: Condition is false
49.       c = EVP_MD_CTX_new();
50.       if (!TEST_ptr(c)
51.           || !TEST_true(EVP_DigestInit_ex(c, EVP_mdc2(), NULL))
                  ^
52.           || !TEST_true(EVP_DigestUpdate(c, (unsigned char *)text, tlen))
53.           || !TEST_true(EVP_DigestFinal_ex(c, &(md[0]), NULL))

test/testutil/tests.c:235:1: start of procedure test_true()
  233.   }
  234.   
  235. > int test_true(const char *file, int line, const char *s, int b)
  236.   {
  237.       if (b)

test/testutil/tests.c:237:9: Taking false branch
  235.   int test_true(const char *file, int line, const char *s, int b)
  236.   {
  237.       if (b)
                 ^
  238.           return 1;
  239.       test_fail_message(NULL, file, line, "bool", s, "true", "==", "false");

test/testutil/tests.c:239:5: Skipping test_fail_message(): empty list of specs
  237.       if (b)
  238.           return 1;
  239.       test_fail_message(NULL, file, line, "bool", s, "true", "==", "false");
             ^
  240.       return 0;
  241.   }

test/testutil/tests.c:240:5: 
  238.           return 1;
  239.       test_fail_message(NULL, file, line, "bool", s, "true", "==", "false");
  240. >     return 0;
  241.   }
  242.   

test/testutil/tests.c:241:1: return from a call to test_true
  239.       test_fail_message(NULL, file, line, "bool", s, "true", "==", "false");
  240.       return 0;
  241. > }
  242.   
  243.   int test_false(const char *file, int line, const char *s, int b)

test/mdc2test.c:51:13: Taking true branch
49.       c = EVP_MD_CTX_new();
50.       if (!TEST_ptr(c)
51.           || !TEST_true(EVP_DigestInit_ex(c, EVP_mdc2(), NULL))
                  ^
52.           || !TEST_true(EVP_DigestUpdate(c, (unsigned char *)text, tlen))
53.           || !TEST_true(EVP_DigestFinal_ex(c, &(md[0]), NULL))

test/mdc2test.c:66:2: 
64.   
65.       testresult = 1;
66. >  end:
67.       EVP_MD_CTX_free(c);
68.       return testresult;

test/mdc2test.c:67:5: 
65.       testresult = 1;
66.    end:
67. >     EVP_MD_CTX_free(c);
68.       return testresult;
69.   }

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:286:1: start of procedure CRYPTO_free()
    284.   }
    285.   
    286. > void CRYPTO_free(void *str, const char *file, int line)
    287.   {
    288.       INCREMENT(free_count);

crypto/mem.c:289:9: Taking true branch
    287.   {
    288.       INCREMENT(free_count);
    289.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    290.           free_impl(str, file, line);
    291.           return;

crypto/mem.c:289:30: Taking true branch
    287.   {
    288.       INCREMENT(free_count);
    289.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                                        ^
    290.           free_impl(str, file, line);
    291.           return;

crypto/mem.c:290:9: Skipping __function_pointer__(): unresolved function pointer
    288.       INCREMENT(free_count);
    289.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    290.           free_impl(str, file, line);
                   ^
    291.           return;
    292.       }

crypto/mem.c:291:9: 
    289.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    290.           free_impl(str, file, line);
    291. >         return;
    292.       }
    293.   

crypto/mem.c:305:1: return from a call to CRYPTO_free
    303.       free(str);
    304.   #endif
    305. > }
    306.   
    307.   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)

static int test_mdc2(void)
{
    int testresult = 0;
    unsigned char md[MDC2_DIGEST_LENGTH];
    EVP_MD_CTX *c;
    static char text[] = "Now is the time for all ";
    size_t tlen = strlen(text);
# ifdef CHARSET_EBCDIC
    ebcdic2ascii(text, text, tlen);
# endif
    c = EVP_MD_CTX_new();
    if (!TEST_ptr(c)
        || !TEST_true(EVP_DigestInit_ex(c, EVP_mdc2(), NULL))
        || !TEST_true(EVP_DigestUpdate(c, (unsigned char *)text, tlen))
        || !TEST_true(EVP_DigestFinal_ex(c, &(md[0]), NULL))
        || !TEST_mem_eq(md, MDC2_DIGEST_LENGTH, pad1, MDC2_DIGEST_LENGTH)
        || !TEST_true(EVP_DigestInit_ex(c, EVP_mdc2(), NULL)))
        goto end;
    ((MDC2_CTX *)EVP_MD_CTX_md_data(c))->pad_type = 2;
    if (!TEST_true(EVP_DigestUpdate(c, (unsigned char *)text, tlen))
        || !TEST_true(EVP_DigestFinal_ex(c, &(md[0]), NULL))
        || !TEST_mem_eq(md, MDC2_DIGEST_LENGTH, pad2, MDC2_DIGEST_LENGTH))
        goto end;
    testresult = 1;
 end:
    EVP_MD_CTX_free(c);
    return testresult;
}
['static int test_mdc2(void)\n{\n    int testresult = 0;\n    unsigned char md[MDC2_DIGEST_LENGTH];\n    EVP_MD_CTX *c;\n    static char text[] = "Now is the time for all ";\n    size_t tlen = strlen(text);\n# ifdef CHARSET_EBCDIC\n    ebcdic2ascii(text, text, tlen);\n# endif\n    c = EVP_MD_CTX_new();\n    if (!TEST_ptr(c)\n        || !TEST_true(EVP_DigestInit_ex(c, EVP_mdc2(), NULL))\n        || !TEST_true(EVP_DigestUpdate(c, (unsigned char *)text, tlen))\n        || !TEST_true(EVP_DigestFinal_ex(c, &(md[0]), NULL))\n        || !TEST_mem_eq(md, MDC2_DIGEST_LENGTH, pad1, MDC2_DIGEST_LENGTH)\n        || !TEST_true(EVP_DigestInit_ex(c, EVP_mdc2(), NULL)))\n        goto end;\n    ((MDC2_CTX *)EVP_MD_CTX_md_data(c))->pad_type = 2;\n    if (!TEST_true(EVP_DigestUpdate(c, (unsigned char *)text, tlen))\n        || !TEST_true(EVP_DigestFinal_ex(c, &(md[0]), NULL))\n        || !TEST_mem_eq(md, MDC2_DIGEST_LENGTH, pad2, MDC2_DIGEST_LENGTH))\n        goto end;\n    testresult = 1;\n end:\n    EVP_MD_CTX_free(c);\n    return testresult;\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    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    INCREMENT(malloc_count);\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    (void)(file); (void)(line);\n    ret = malloc(num);\n#endif\n    return ret;\n}', 'int test_ptr(const char *file, int line, const char *s, const void *p)\n{\n    if (p != NULL)\n        return 1;\n    test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);\n    return 0;\n}', 'const EVP_MD *EVP_mdc2(void)\n{\n    return &mdc2_md;\n}', 'int test_true(const char *file, int line, const char *s, int b)\n{\n    if (b)\n        return 1;\n    test_fail_message(NULL, file, line, "bool", s, "true", "==", "false");\n    return 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    INCREMENT(free_count);\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}']