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


test/evp_test.c:1831:1: start of procedure encode_test_init()
1829.   };
1830.   
1831. > static int encode_test_init(struct evp_test *t, const char *encoding)
1832.   {
1833.       struct encode_data *edata = OPENSSL_zalloc(sizeof(*edata));

test/evp_test.c:1833:5: 
1831.   static int encode_test_init(struct evp_test *t, const char *encoding)
1832.   {
1833. >     struct encode_data *edata = OPENSSL_zalloc(sizeof(*edata));
1834.   
1835.       if (strcmp(encoding, "canonical") == 0) {

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)

test/evp_test.c:1835:9: Taking false branch
1833.       struct encode_data *edata = OPENSSL_zalloc(sizeof(*edata));
1834.   
1835.       if (strcmp(encoding, "canonical") == 0) {
                ^
1836.           edata->encoding = BASE64_CANONICAL_ENCODING;
1837.       } else if (strcmp(encoding, "valid") == 0) {

test/evp_test.c:1837:16: Taking false branch
1835.       if (strcmp(encoding, "canonical") == 0) {
1836.           edata->encoding = BASE64_CANONICAL_ENCODING;
1837.       } else if (strcmp(encoding, "valid") == 0) {
                       ^
1838.           edata->encoding = BASE64_VALID_ENCODING;
1839.       } else if (strcmp(encoding, "invalid") == 0) {

test/evp_test.c:1839:16: Taking true branch
1837.       } else if (strcmp(encoding, "valid") == 0) {
1838.           edata->encoding = BASE64_VALID_ENCODING;
1839.       } else if (strcmp(encoding, "invalid") == 0) {
                       ^
1840.           edata->encoding = BASE64_INVALID_ENCODING;
1841.           t->expected_err = OPENSSL_strdup("DECODE_ERROR");

test/evp_test.c:1840:9: 
1838.           edata->encoding = BASE64_VALID_ENCODING;
1839.       } else if (strcmp(encoding, "invalid") == 0) {
1840. >         edata->encoding = BASE64_INVALID_ENCODING;
1841.           t->expected_err = OPENSSL_strdup("DECODE_ERROR");
1842.           if (t->expected_err == NULL)

test/evp_test.c:1841:9: 
1839.       } else if (strcmp(encoding, "invalid") == 0) {
1840.           edata->encoding = BASE64_INVALID_ENCODING;
1841. >         t->expected_err = OPENSSL_strdup("DECODE_ERROR");
1842.           if (t->expected_err == NULL)
1843.               return 0;

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

crypto/o_str.c:33:9: Taking false branch
  31.       size_t size;
  32.   
  33.       if (str == NULL)
                ^
  34.           return NULL;
  35.       size = strlen(str) + 1;

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

crypto/o_str.c:36:5: 
  34.           return NULL;
  35.       size = strlen(str) + 1;
  36. >     ret = CRYPTO_malloc(size, file, line);
  37.       if (ret != NULL)
  38.           memcpy(ret, str, size);

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 true branch
    163.           return malloc_impl(num, file, line);
    164.   
    165.       if (num <= 0)
                   ^
    166.           return NULL;
    167.   

crypto/mem.c:166:9: 
    164.   
    165.       if (num <= 0)
    166. >         return NULL;
    167.   
    168.       FAILTEST();

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/o_str.c:37:9: Taking false branch
  35.       size = strlen(str) + 1;
  36.       ret = CRYPTO_malloc(size, file, line);
  37.       if (ret != NULL)
                ^
  38.           memcpy(ret, str, size);
  39.       return ret;

crypto/o_str.c:39:5: 
  37.       if (ret != NULL)
  38.           memcpy(ret, str, size);
  39. >     return ret;
  40.   }
  41.   

crypto/o_str.c:40:1: return from a call to CRYPTO_strdup
  38.           memcpy(ret, str, size);
  39.       return ret;
  40. > }
  41.   
  42.   char *CRYPTO_strndup(const char *str, size_t s, const char* file, int line)

test/evp_test.c:1842:13: Taking true branch
1840.           edata->encoding = BASE64_INVALID_ENCODING;
1841.           t->expected_err = OPENSSL_strdup("DECODE_ERROR");
1842.           if (t->expected_err == NULL)
                    ^
1843.               return 0;
1844.       } else {

test/evp_test.c:1843:13: 
1841.           t->expected_err = OPENSSL_strdup("DECODE_ERROR");
1842.           if (t->expected_err == NULL)
1843. >             return 0;
1844.       } else {
1845.           fprintf(stderr, "Bad encoding: %s. Should be one of "

static int encode_test_init(struct evp_test *t, const char *encoding)
{
    struct encode_data *edata = OPENSSL_zalloc(sizeof(*edata));
    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;
        t->expected_err = OPENSSL_strdup("DECODE_ERROR");
        if (t->expected_err == NULL)
            return 0;
    } else {
        fprintf(stderr, "Bad encoding: %s. Should be one of "
                "{canonical, valid, invalid}\n", encoding);
        return 0;
    }
    t->data = edata;
    return 1;
}
['static int encode_test_init(struct evp_test *t, const char *encoding)\n{\n    struct encode_data *edata = OPENSSL_zalloc(sizeof(*edata));\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        t->expected_err = OPENSSL_strdup("DECODE_ERROR");\n        if (t->expected_err == NULL)\n            return 0;\n    } else {\n        fprintf(stderr, "Bad encoding: %s. Should be one of "\n                "{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    osslargused(file); osslargused(line);\n    ret = malloc(num);\n#endif\n    return ret;\n}', 'char *CRYPTO_strdup(const char *str, const char* file, int line)\n{\n    char *ret;\n    size_t size;\n    if (str == NULL)\n        return NULL;\n    size = strlen(str) + 1;\n    ret = CRYPTO_malloc(size, file, line);\n    if (ret != NULL)\n        memcpy(ret, str, size);\n    return ret;\n}']