test/lhash_test.c:185: error: MEMORY_LEAK
  memory dynamically allocated by call to `CRYPTO_malloc()` at line 179, column 13 is not reachable after line 185, column 9.
Showing all 45 steps of the trace


test/lhash_test.c:167:1: start of procedure test_stress()
165.   }
166.   
167. > static int test_stress(void)
168.   {
169.       LHASH_OF(int) *h = lh_int_new(&stress_hash, &int_cmp);

test/lhash_test.c:169:5: 
167.   static int test_stress(void)
168.   {
169. >     LHASH_OF(int) *h = lh_int_new(&stress_hash, &int_cmp);
170.       const unsigned int n = 2500000;
171.       unsigned int i;

test/lhash_test.c:30:1: start of procedure lh_int_new()
  28.   #endif
  29.   
  30. > DEFINE_LHASH_OF(int);
  31.   
  32.   static int int_tests[] = { 65537, 13, 1, 3, -5, 6, 7, 4, -10, -12, -14, 22, 9,

test/lhash_test.c:30:1: return from a call to lh_int_new
  28.   #endif
  29.   
  30. > DEFINE_LHASH_OF(int);
  31.   
  32.   static int int_tests[] = { 65537, 13, 1, 3, -5, 6, 7, 4, -10, -12, -14, 22, 9,

test/lhash_test.c:170:5: 
168.   {
169.       LHASH_OF(int) *h = lh_int_new(&stress_hash, &int_cmp);
170. >     const unsigned int n = 2500000;
171.       unsigned int i;
172.       int testresult = 0, *p;

test/lhash_test.c:172:5: 
170.       const unsigned int n = 2500000;
171.       unsigned int i;
172. >     int testresult = 0, *p;
173.   
174.       if (!TEST_ptr(h))

test/lhash_test.c:174:10: 
172.       int testresult = 0, *p;
173.   
174. >     if (!TEST_ptr(h))
175.           goto end;
176.   

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/lhash_test.c:174:10: Taking false branch
172.       int testresult = 0, *p;
173.   
174.       if (!TEST_ptr(h))
                ^
175.           goto end;
176.   

test/lhash_test.c:178:10: 
176.   
177.       /* insert */
178. >     for (i = 0; i < n; i++) {
179.           p = OPENSSL_malloc(sizeof(i));
180.           if (!TEST_ptr(p)) {

test/lhash_test.c:178:17: Loop condition is true. Entering loop body
176.   
177.       /* insert */
178.       for (i = 0; i < n; i++) {
                       ^
179.           p = OPENSSL_malloc(sizeof(i));
180.           if (!TEST_ptr(p)) {

test/lhash_test.c:179:9: 
177.       /* insert */
178.       for (i = 0; i < n; i++) {
179. >         p = OPENSSL_malloc(sizeof(i));
180.           if (!TEST_ptr(p)) {
181.               TEST_info("lhash stress out of memory %d", i);

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

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

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

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

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

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

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

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

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

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

test/lhash_test.c:180:14: 
178.       for (i = 0; i < n; i++) {
179.           p = OPENSSL_malloc(sizeof(i));
180. >         if (!TEST_ptr(p)) {
181.               TEST_info("lhash stress out of memory %d", i);
182.               goto end;

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/lhash_test.c:180:14: Taking false branch
178.       for (i = 0; i < n; i++) {
179.           p = OPENSSL_malloc(sizeof(i));
180.           if (!TEST_ptr(p)) {
                    ^
181.               TEST_info("lhash stress out of memory %d", i);
182.               goto end;

test/lhash_test.c:184:9: 
182.               goto end;
183.           }
184. >         *p = 3 * i + 1;
185.           lh_int_insert(h, p);
186.       }

test/lhash_test.c:185:9: 
183.           }
184.           *p = 3 * i + 1;
185. >         lh_int_insert(h, p);
186.       }
187.   

test/lhash_test.c:30:1: start of procedure lh_int_insert()
  28.   #endif
  29.   
  30. > DEFINE_LHASH_OF(int);
  31.   
  32.   static int int_tests[] = { 65537, 13, 1, 3, -5, 6, 7, 4, -10, -12, -14, 22, 9,

crypto/lhash/lhash.c:73:1: start of procedure OPENSSL_LH_insert()
    71.   }
    72.   
    73. > void *OPENSSL_LH_insert(OPENSSL_LHASH *lh, void *data)
    74.   {
    75.       unsigned long hash;

crypto/lhash/lhash.c:79:5: 
    77.       void *ret;
    78.   
    79. >     lh->error = 0;
    80.       if ((lh->up_load <= (lh->num_items * LH_LOAD_MULT / lh->num_nodes)) && !expand(lh))
    81.           return NULL;        /* 'lh->error++' already done in 'expand' */

crypto/lhash/lhash.c:80:10: Taking false branch
    78.   
    79.       lh->error = 0;
    80.       if ((lh->up_load <= (lh->num_items * LH_LOAD_MULT / lh->num_nodes)) && !expand(lh))
                   ^
    81.           return NULL;        /* 'lh->error++' already done in 'expand' */
    82.   

crypto/lhash/lhash.c:83:5: Skipping getrn(): empty list of specs
    81.           return NULL;        /* 'lh->error++' already done in 'expand' */
    82.   
    83.       rn = getrn(lh, data, &hash);
              ^
    84.   
    85.       if (*rn == NULL) {

crypto/lhash/lhash.c:85:9: Taking false branch
    83.       rn = getrn(lh, data, &hash);
    84.   
    85.       if (*rn == NULL) {
                  ^
    86.           if ((nn = OPENSSL_malloc(sizeof(*nn))) == NULL) {
    87.               lh->error++;

crypto/lhash/lhash.c:99:9: 
    97.       } else {                    /* replace same key */
    98.   
    99. >         ret = (*rn)->data;
    100.           (*rn)->data = data;
    101.           lh->num_replace++;

crypto/lhash/lhash.c:100:9: 
    98.   
    99.           ret = (*rn)->data;
    100. >         (*rn)->data = data;
    101.           lh->num_replace++;
    102.       }

crypto/lhash/lhash.c:101:9: 
    99.           ret = (*rn)->data;
    100.           (*rn)->data = data;
    101. >         lh->num_replace++;
    102.       }
    103.       return (ret);

crypto/lhash/lhash.c:103:5: 
    101.           lh->num_replace++;
    102.       }
    103. >     return (ret);
    104.   }
    105.   

crypto/lhash/lhash.c:104:1: return from a call to OPENSSL_LH_insert
    102.       }
    103.       return (ret);
    104. > }
    105.   
    106.   void *OPENSSL_LH_delete(OPENSSL_LHASH *lh, const void *data)

test/lhash_test.c:30:1: return from a call to lh_int_insert
  28.   #endif
  29.   
  30. > DEFINE_LHASH_OF(int);
  31.   
  32.   static int int_tests[] = { 65537, 13, 1, 3, -5, 6, 7, 4, -10, -12, -14, 22, 9,

static int test_stress(void)
{
    LHASH_OF(int) *h = lh_int_new(&stress_hash, &int_cmp);
    const unsigned int n = 2500000;
    unsigned int i;
    int testresult = 0, *p;
    if (!TEST_ptr(h))
        goto end;
    for (i = 0; i < n; i++) {
        p = OPENSSL_malloc(sizeof(i));
        if (!TEST_ptr(p)) {
            TEST_info("lhash stress out of memory %d", i);
            goto end;
        }
        *p = 3 * i + 1;
        lh_int_insert(h, p);
    }
    if (!TEST_int_eq(lh_int_num_items(h), n))
            goto end;
    TEST_info("hash full statistics:");
    OPENSSL_LH_stats_bio((OPENSSL_LHASH *)h, bio_err);
    TEST_note("hash full node usage:");
    OPENSSL_LH_node_usage_stats_bio((OPENSSL_LHASH *)h, bio_err);
    for (i = 0; i < n; i++) {
        const int j = (7 * i + 4) % n * 3 + 1;
        if (!TEST_ptr(p = lh_int_delete(h, &j))) {
            TEST_info("lhash stress delete %d\n", i);
            goto end;
        }
        if (!TEST_int_eq(*p, j)) {
            TEST_info("lhash stress bad value %d", i);
            goto end;
        }
        OPENSSL_free(p);
    }
    TEST_info("hash empty statistics:");
    OPENSSL_LH_stats_bio((OPENSSL_LHASH *)h, bio_err);
    TEST_note("hash empty node usage:");
    OPENSSL_LH_node_usage_stats_bio((OPENSSL_LHASH *)h, bio_err);
    testresult = 1;
end:
    lh_int_free(h);
    return testresult;
}
['static int test_stress(void)\n{\n    LHASH_OF(int) *h = lh_int_new(&stress_hash, &int_cmp);\n    const unsigned int n = 2500000;\n    unsigned int i;\n    int testresult = 0, *p;\n    if (!TEST_ptr(h))\n        goto end;\n    for (i = 0; i < n; i++) {\n        p = OPENSSL_malloc(sizeof(i));\n        if (!TEST_ptr(p)) {\n            TEST_info("lhash stress out of memory %d", i);\n            goto end;\n        }\n        *p = 3 * i + 1;\n        lh_int_insert(h, p);\n    }\n    if (!TEST_int_eq(lh_int_num_items(h), n))\n            goto end;\n    TEST_info("hash full statistics:");\n    OPENSSL_LH_stats_bio((OPENSSL_LHASH *)h, bio_err);\n    TEST_note("hash full node usage:");\n    OPENSSL_LH_node_usage_stats_bio((OPENSSL_LHASH *)h, bio_err);\n    for (i = 0; i < n; i++) {\n        const int j = (7 * i + 4) % n * 3 + 1;\n        if (!TEST_ptr(p = lh_int_delete(h, &j))) {\n            TEST_info("lhash stress delete %d\\n", i);\n            goto end;\n        }\n        if (!TEST_int_eq(*p, j)) {\n            TEST_info("lhash stress bad value %d", i);\n            goto end;\n        }\n        OPENSSL_free(p);\n    }\n    TEST_info("hash empty statistics:");\n    OPENSSL_LH_stats_bio((OPENSSL_LHASH *)h, bio_err);\n    TEST_note("hash empty node usage:");\n    OPENSSL_LH_node_usage_stats_bio((OPENSSL_LHASH *)h, bio_err);\n    testresult = 1;\nend:\n    lh_int_free(h);\n    return testresult;\n}', 'DEFINE_LHASH_OF(int)', '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}', '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}', 'void *OPENSSL_LH_insert(OPENSSL_LHASH *lh, void *data)\n{\n    unsigned long hash;\n    OPENSSL_LH_NODE *nn, **rn;\n    void *ret;\n    lh->error = 0;\n    if ((lh->up_load <= (lh->num_items * LH_LOAD_MULT / lh->num_nodes)) && !expand(lh))\n        return NULL;\n    rn = getrn(lh, data, &hash);\n    if (*rn == NULL) {\n        if ((nn = OPENSSL_malloc(sizeof(*nn))) == NULL) {\n            lh->error++;\n            return (NULL);\n        }\n        nn->data = data;\n        nn->next = NULL;\n        nn->hash = hash;\n        *rn = nn;\n        ret = NULL;\n        lh->num_insert++;\n        lh->num_items++;\n    } else {\n        ret = (*rn)->data;\n        (*rn)->data = data;\n        lh->num_replace++;\n    }\n    return (ret);\n}']