test/exdatatest.c:206: error: MEMORY_LEAK
  memory dynamically allocated by call to `CRYPTO_strdup()` at line 195, column 9 is not reachable after line 206, column 10.
Showing all 42 steps of the trace


test/exdatatest.c:186:1: start of procedure test_exdata()
184.   }
185.   
186. > static int test_exdata(void)
187.   {
188.       MYOBJ *t1, *t2, *t3;

test/exdatatest.c:193:5: 
191.       char *p;
192.   
193. >     gbl_result = 1;
194.   
195.       p = OPENSSL_strdup("hello world");

test/exdatatest.c:195:5: 
193.       gbl_result = 1;
194.   
195. >     p = OPENSSL_strdup("hello world");
196.       saved_argl = 21;
197.       saved_argp = OPENSSL_malloc(1);

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 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/o_str.c:37:9: Taking true 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:38:9: 
  36.       ret = CRYPTO_malloc(size, file, line);
  37.       if (ret != NULL)
  38. >         memcpy(ret, str, size);
  39.       return ret;
  40.   }

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/exdatatest.c:196:5: 
194.   
195.       p = OPENSSL_strdup("hello world");
196. >     saved_argl = 21;
197.       saved_argp = OPENSSL_malloc(1);
198.       saved_idx = CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_APP,

test/exdatatest.c:197:5: 
195.       p = OPENSSL_strdup("hello world");
196.       saved_argl = 21;
197. >     saved_argp = OPENSSL_malloc(1);
198.       saved_idx = CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_APP,
199.                                           saved_argl, saved_argp,

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)

test/exdatatest.c:198:5: Skipping CRYPTO_get_ex_new_index(): empty list of specs
196.       saved_argl = 21;
197.       saved_argp = OPENSSL_malloc(1);
198.       saved_idx = CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_APP,
           ^
199.                                           saved_argl, saved_argp,
200.                                           exnew, exdup, exfree);

test/exdatatest.c:201:5: Skipping CRYPTO_get_ex_new_index(): empty list of specs
199.                                           saved_argl, saved_argp,
200.                                           exnew, exdup, exfree);
201.       saved_idx2 = CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_APP,
           ^
202.                                            saved_argl, saved_argp,
203.                                            exnew2, exdup2, exfree2);

test/exdatatest.c:204:5: Skipping MYOBJ_new(): empty list of specs
202.                                            saved_argl, saved_argp,
203.                                            exnew2, exdup2, exfree2);
204.       t1 = MYOBJ_new();
           ^
205.       t2 = MYOBJ_new();
206.       if (!TEST_int_eq(t1->st, 1) || !TEST_int_eq(t2->st, 1))

test/exdatatest.c:205:5: Skipping MYOBJ_new(): empty list of specs
203.                                            exnew2, exdup2, exfree2);
204.       t1 = MYOBJ_new();
205.       t2 = MYOBJ_new();
           ^
206.       if (!TEST_int_eq(t1->st, 1) || !TEST_int_eq(t2->st, 1))
207.           return 0;

test/exdatatest.c:206:10: 
204.       t1 = MYOBJ_new();
205.       t2 = MYOBJ_new();
206. >     if (!TEST_int_eq(t1->st, 1) || !TEST_int_eq(t2->st, 1))
207.           return 0;
208.       if (!TEST_ptr(CRYPTO_get_ex_data(&t1->ex_data, saved_idx2)))

test/testutil/tests.c:198:1: start of procedure test_int_eq()
  196.       DEFINE_COMPARISON(type, name, ge, >=, fmt)
  197.   
  198. > DEFINE_COMPARISONS(int, int, "%d")
  199.   DEFINE_COMPARISONS(unsigned int, uint, "%u")
  200.   DEFINE_COMPARISONS(char, char, "%c")

test/testutil/tests.c:198:1: Taking false branch
  196.       DEFINE_COMPARISON(type, name, ge, >=, fmt)
  197.   
  198. > DEFINE_COMPARISONS(int, int, "%d")
  199.   DEFINE_COMPARISONS(unsigned int, uint, "%u")
  200.   DEFINE_COMPARISONS(char, char, "%c")

test/testutil/tests.c:198:1: return from a call to test_int_eq
  196.       DEFINE_COMPARISON(type, name, ge, >=, fmt)
  197.   
  198. > DEFINE_COMPARISONS(int, int, "%d")
  199.   DEFINE_COMPARISONS(unsigned int, uint, "%u")
  200.   DEFINE_COMPARISONS(char, char, "%c")

test/exdatatest.c:206:10: Taking true branch
204.       t1 = MYOBJ_new();
205.       t2 = MYOBJ_new();
206.       if (!TEST_int_eq(t1->st, 1) || !TEST_int_eq(t2->st, 1))
                ^
207.           return 0;
208.       if (!TEST_ptr(CRYPTO_get_ex_data(&t1->ex_data, saved_idx2)))

static int test_exdata(void)
{
    MYOBJ *t1, *t2, *t3;
    MYOBJ_EX_DATA *ex_data;
    const char *cp;
    char *p;
    gbl_result = 1;
    p = OPENSSL_strdup("hello world");
    saved_argl = 21;
    saved_argp = OPENSSL_malloc(1);
    saved_idx = CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_APP,
                                        saved_argl, saved_argp,
                                        exnew, exdup, exfree);
    saved_idx2 = CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_APP,
                                         saved_argl, saved_argp,
                                         exnew2, exdup2, exfree2);
    t1 = MYOBJ_new();
    t2 = MYOBJ_new();
    if (!TEST_int_eq(t1->st, 1) || !TEST_int_eq(t2->st, 1))
        return 0;
    if (!TEST_ptr(CRYPTO_get_ex_data(&t1->ex_data, saved_idx2)))
        return 0;
    if (!TEST_ptr(CRYPTO_get_ex_data(&t2->ex_data, saved_idx2)))
        return 0;
    MYOBJ_sethello(t1, p);
    cp = MYOBJ_gethello(t1);
    if (!TEST_ptr_eq(cp, p))
        return 0;
    MYOBJ_sethello2(t1, p);
    cp = MYOBJ_gethello2(t1);
    if (!TEST_ptr_eq(cp, p))
        return 0;
    cp = MYOBJ_gethello(t2);
    if (!TEST_ptr_null(cp))
        return 0;
    cp = MYOBJ_gethello2(t2);
    if (!TEST_ptr_null(cp))
        return 0;
    t3 = MYOBJ_dup(t1);
    if (!TEST_int_eq(t3->st, 1))
        return 0;
    ex_data = CRYPTO_get_ex_data(&t3->ex_data, saved_idx2);
    if (!TEST_ptr(ex_data))
        return 0;
    if (!TEST_int_eq(ex_data->dup, 1))
        return 0;
    cp = MYOBJ_gethello(t3);
    if (!TEST_ptr_eq(cp, p))
        return 0;
    cp = MYOBJ_gethello2(t3);
    if (!TEST_ptr_eq(cp, p))
        return 0;
    MYOBJ_free(t1);
    MYOBJ_free(t2);
    MYOBJ_free(t3);
    OPENSSL_free(saved_argp);
    OPENSSL_free(p);
    if (gbl_result)
      return 1;
    else
      return 0;
}
['static int test_exdata(void)\n{\n    MYOBJ *t1, *t2, *t3;\n    MYOBJ_EX_DATA *ex_data;\n    const char *cp;\n    char *p;\n    gbl_result = 1;\n    p = OPENSSL_strdup("hello world");\n    saved_argl = 21;\n    saved_argp = OPENSSL_malloc(1);\n    saved_idx = CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_APP,\n                                        saved_argl, saved_argp,\n                                        exnew, exdup, exfree);\n    saved_idx2 = CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_APP,\n                                         saved_argl, saved_argp,\n                                         exnew2, exdup2, exfree2);\n    t1 = MYOBJ_new();\n    t2 = MYOBJ_new();\n    if (!TEST_int_eq(t1->st, 1) || !TEST_int_eq(t2->st, 1))\n        return 0;\n    if (!TEST_ptr(CRYPTO_get_ex_data(&t1->ex_data, saved_idx2)))\n        return 0;\n    if (!TEST_ptr(CRYPTO_get_ex_data(&t2->ex_data, saved_idx2)))\n        return 0;\n    MYOBJ_sethello(t1, p);\n    cp = MYOBJ_gethello(t1);\n    if (!TEST_ptr_eq(cp, p))\n        return 0;\n    MYOBJ_sethello2(t1, p);\n    cp = MYOBJ_gethello2(t1);\n    if (!TEST_ptr_eq(cp, p))\n        return 0;\n    cp = MYOBJ_gethello(t2);\n    if (!TEST_ptr_null(cp))\n        return 0;\n    cp = MYOBJ_gethello2(t2);\n    if (!TEST_ptr_null(cp))\n        return 0;\n    t3 = MYOBJ_dup(t1);\n    if (!TEST_int_eq(t3->st, 1))\n        return 0;\n    ex_data = CRYPTO_get_ex_data(&t3->ex_data, saved_idx2);\n    if (!TEST_ptr(ex_data))\n        return 0;\n    if (!TEST_int_eq(ex_data->dup, 1))\n        return 0;\n    cp = MYOBJ_gethello(t3);\n    if (!TEST_ptr_eq(cp, p))\n        return 0;\n    cp = MYOBJ_gethello2(t3);\n    if (!TEST_ptr_eq(cp, p))\n        return 0;\n    MYOBJ_free(t1);\n    MYOBJ_free(t2);\n    MYOBJ_free(t3);\n    OPENSSL_free(saved_argp);\n    OPENSSL_free(p);\n    if (gbl_result)\n      return 1;\n    else\n      return 0;\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}', '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}', 'DEFINE_COMPARISONS(int, int, "%d")']