test/evp_test.c:1511: error: MEMORY_LEAK
  memory dynamically allocated to `return` by call to `CRYPTO_zalloc()` at line 1502, column 10 is not reachable after line 1511, column 13.
Showing all 47 steps of the trace


test/evp_test.c:1498:1: start of procedure encode_test_init()
1496.   } ENCODE_DATA;
1497.   
1498. > static int encode_test_init(EVP_TEST *t, const char *encoding)
1499.   {
1500.       ENCODE_DATA *edata;

test/evp_test.c:1502:10: 
1500.       ENCODE_DATA *edata;
1501.   
1502. >     if (!TEST_ptr(edata = OPENSSL_zalloc(sizeof(*edata))))
1503.           return 0;
1504.       if (strcmp(encoding, "canonical") == 0) {

crypto/mem.c:198:1: start of procedure CRYPTO_zalloc()
  196.   }
  197.   
  198. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
  199.   {
  200.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:200:5: 
  198.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
  199.   {
  200. >     void *ret = CRYPTO_malloc(num, file, line);
  201.   
  202.       FAILTEST();

crypto/mem.c:170:1: start of procedure CRYPTO_malloc()
    168.   #endif
    169.   
    170. > void *CRYPTO_malloc(size_t num, const char *file, int line)
    171.   {
    172.       void *ret = NULL;

crypto/mem.c:172:5: 
    170.   void *CRYPTO_malloc(size_t num, const char *file, int line)
    171.   {
    172. >     void *ret = NULL;
    173.   
    174.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:174:9: Taking false branch
    172.       void *ret = NULL;
    173.   
    174.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                   ^
    175.           return malloc_impl(num, file, line);
    176.   

crypto/mem.c:177:9: Taking false branch
    175.           return malloc_impl(num, file, line);
    176.   
    177.       if (num == 0)
                   ^
    178.           return NULL;
    179.   

crypto/mem.c:181:5: 
    179.   
    180.       FAILTEST();
    181. >     allow_customize = 0;
    182.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
    183.       if (call_malloc_debug) {

crypto/mem.c:191:5: 
    189.       }
    190.   #else
    191. >     (void)(file); (void)(line);
    192.       ret = malloc(num);
    193.   #endif

crypto/mem.c:191:19: 
    189.       }
    190.   #else
    191. >     (void)(file); (void)(line);
    192.       ret = malloc(num);
    193.   #endif

crypto/mem.c:192:5: 
    190.   #else
    191.       (void)(file); (void)(line);
    192. >     ret = malloc(num);
    193.   #endif
    194.   

crypto/mem.c:195:5: 
    193.   #endif
    194.   
    195. >     return ret;
    196.   }
    197.   

crypto/mem.c:196:1: return from a call to CRYPTO_malloc
    194.   
    195.       return ret;
    196. > }
    197.   
    198.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:203:9: Taking true branch
  201.   
  202.       FAILTEST();
  203.       if (ret != NULL)
                 ^
  204.           memset(ret, 0, num);
  205.       return ret;

crypto/mem.c:204:9: 
  202.       FAILTEST();
  203.       if (ret != NULL)
  204. >         memset(ret, 0, num);
  205.       return ret;
  206.   }

crypto/mem.c:205:5: 
  203.       if (ret != NULL)
  204.           memset(ret, 0, num);
  205. >     return ret;
  206.   }
  207.   

crypto/mem.c:206:1: return from a call to CRYPTO_zalloc
  204.           memset(ret, 0, num);
  205.       return ret;
  206. > }
  207.   
  208.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

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/evp_test.c:1502:10: Taking false branch
1500.       ENCODE_DATA *edata;
1501.   
1502.       if (!TEST_ptr(edata = OPENSSL_zalloc(sizeof(*edata))))
                 ^
1503.           return 0;
1504.       if (strcmp(encoding, "canonical") == 0) {

test/evp_test.c:1504:9: Taking false branch
1502.       if (!TEST_ptr(edata = OPENSSL_zalloc(sizeof(*edata))))
1503.           return 0;
1504.       if (strcmp(encoding, "canonical") == 0) {
                ^
1505.           edata->encoding = BASE64_CANONICAL_ENCODING;
1506.       } else if (strcmp(encoding, "valid") == 0) {

test/evp_test.c:1506:16: Taking false branch
1504.       if (strcmp(encoding, "canonical") == 0) {
1505.           edata->encoding = BASE64_CANONICAL_ENCODING;
1506.       } else if (strcmp(encoding, "valid") == 0) {
                       ^
1507.           edata->encoding = BASE64_VALID_ENCODING;
1508.       } else if (strcmp(encoding, "invalid") == 0) {

test/evp_test.c:1508:16: Taking true branch
1506.       } else if (strcmp(encoding, "valid") == 0) {
1507.           edata->encoding = BASE64_VALID_ENCODING;
1508.       } else if (strcmp(encoding, "invalid") == 0) {
                       ^
1509.           edata->encoding = BASE64_INVALID_ENCODING;
1510.           if (!TEST_ptr(t->expected_err = OPENSSL_strdup("DECODE_ERROR")))

test/evp_test.c:1509:9: 
1507.           edata->encoding = BASE64_VALID_ENCODING;
1508.       } else if (strcmp(encoding, "invalid") == 0) {
1509. >         edata->encoding = BASE64_INVALID_ENCODING;
1510.           if (!TEST_ptr(t->expected_err = OPENSSL_strdup("DECODE_ERROR")))
1511.               return 0;

test/evp_test.c:1510:14: 
1508.       } else if (strcmp(encoding, "invalid") == 0) {
1509.           edata->encoding = BASE64_INVALID_ENCODING;
1510. >         if (!TEST_ptr(t->expected_err = OPENSSL_strdup("DECODE_ERROR")))
1511.               return 0;
1512.       } else {

crypto/o_str.c:27:1: start of procedure CRYPTO_strdup()
  25.   }
  26.   
  27. > char *CRYPTO_strdup(const char *str, const char* file, int line)
  28.   {
  29.       char *ret;

crypto/o_str.c:31:9: Taking false branch
  29.       char *ret;
  30.   
  31.       if (str == NULL)
                ^
  32.           return NULL;
  33.       ret = CRYPTO_malloc(strlen(str) + 1, file, line);

crypto/o_str.c:33:5: 
  31.       if (str == NULL)
  32.           return NULL;
  33. >     ret = CRYPTO_malloc(strlen(str) + 1, file, line);
  34.       if (ret != NULL)
  35.           strcpy(ret, str);

crypto/mem.c:170:1: start of procedure CRYPTO_malloc()
    168.   #endif
    169.   
    170. > void *CRYPTO_malloc(size_t num, const char *file, int line)
    171.   {
    172.       void *ret = NULL;

crypto/mem.c:172:5: 
    170.   void *CRYPTO_malloc(size_t num, const char *file, int line)
    171.   {
    172. >     void *ret = NULL;
    173.   
    174.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:174:9: Taking true branch
    172.       void *ret = NULL;
    173.   
    174.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                   ^
    175.           return malloc_impl(num, file, line);
    176.   

crypto/mem.c:174:32: Taking true branch
    172.       void *ret = NULL;
    173.   
    174.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                                          ^
    175.           return malloc_impl(num, file, line);
    176.   

crypto/mem.c:175:9: Skipping __function_pointer__(): unresolved function pointer
    173.   
    174.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
    175.           return malloc_impl(num, file, line);
                   ^
    176.   
    177.       if (num == 0)

crypto/mem.c:196:1: return from a call to CRYPTO_malloc
    194.   
    195.       return ret;
    196. > }
    197.   
    198.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/o_str.c:34:9: Taking false branch
  32.           return NULL;
  33.       ret = CRYPTO_malloc(strlen(str) + 1, file, line);
  34.       if (ret != NULL)
                ^
  35.           strcpy(ret, str);
  36.       return ret;

crypto/o_str.c:36:5: 
  34.       if (ret != NULL)
  35.           strcpy(ret, str);
  36. >     return ret;
  37.   }
  38.   

crypto/o_str.c:37:1: return from a call to CRYPTO_strdup
  35.           strcpy(ret, str);
  36.       return ret;
  37. > }
  38.   
  39.   char *CRYPTO_strndup(const char *str, size_t s, const char* file, int line)

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 false 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:231:5: Skipping test_fail_message(): empty list of specs
  229.       if (p != NULL)
  230.           return 1;
  231.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
             ^
  232.       return 0;
  233.   }

test/testutil/tests.c:232:5: 
  230.           return 1;
  231.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  232. >     return 0;
  233.   }
  234.   

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/evp_test.c:1510:14: Taking true branch
1508.       } else if (strcmp(encoding, "invalid") == 0) {
1509.           edata->encoding = BASE64_INVALID_ENCODING;
1510.           if (!TEST_ptr(t->expected_err = OPENSSL_strdup("DECODE_ERROR")))
                     ^
1511.               return 0;
1512.       } else {

test/evp_test.c:1511:13: 
1509.           edata->encoding = BASE64_INVALID_ENCODING;
1510.           if (!TEST_ptr(t->expected_err = OPENSSL_strdup("DECODE_ERROR")))
1511. >             return 0;
1512.       } else {
1513.           TEST_error("Bad encoding: %s."

static int encode_test_init(EVP_TEST *t, const char *encoding)
{
    ENCODE_DATA *edata;
    if (!TEST_ptr(edata = OPENSSL_zalloc(sizeof(*edata))))
        return 0;
    if (strcmp(encoding, "canonical") == 0) {
        edata->encoding = BASE64_CANONICAL_ENCODING;
    } else if (strcmp(encoding, "valid") == 0) {
        edata->encoding = BASE64_VALID_ENCODING;
    } else if (strcmp(encoding, "invalid") == 0) {
        edata->encoding = BASE64_INVALID_ENCODING;
        if (!TEST_ptr(t->expected_err = OPENSSL_strdup("DECODE_ERROR")))
            return 0;
    } else {
        TEST_error("Bad encoding: %s."
                   " Should be one of {canonical, valid, invalid}",
                   encoding);
        return 0;
    }
    t->data = edata;
    return 1;
}
['static int encode_test_init(EVP_TEST *t, const char *encoding)\n{\n    ENCODE_DATA *edata;\n    if (!TEST_ptr(edata = OPENSSL_zalloc(sizeof(*edata))))\n        return 0;\n    if (strcmp(encoding, "canonical") == 0) {\n        edata->encoding = BASE64_CANONICAL_ENCODING;\n    } else if (strcmp(encoding, "valid") == 0) {\n        edata->encoding = BASE64_VALID_ENCODING;\n    } else if (strcmp(encoding, "invalid") == 0) {\n        edata->encoding = BASE64_INVALID_ENCODING;\n        if (!TEST_ptr(t->expected_err = OPENSSL_strdup("DECODE_ERROR")))\n            return 0;\n    } else {\n        TEST_error("Bad encoding: %s."\n                   " Should be one of {canonical, valid, invalid}",\n                   encoding);\n        return 0;\n    }\n    t->data = edata;\n    return 1;\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    (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}', 'char *CRYPTO_strdup(const char *str, const char* file, int line)\n{\n    char *ret;\n    if (str == NULL)\n        return NULL;\n    ret = CRYPTO_malloc(strlen(str) + 1, file, line);\n    if (ret != NULL)\n        strcpy(ret, str);\n    return ret;\n}']