test/sparse_array_test.c:94: error: MEMORY_LEAK
  memory dynamically allocated by call to `ossl_sa_char_new()` at line 85, column 17 is not reachable after line 94, column 5.
Showing all 69 steps of the trace


test/sparse_array_test.c:68:1: start of procedure test_sparse_array_num()
66.   }
67.   
68. > static int test_sparse_array_num(void)
69.   {
70.       static const struct {

test/sparse_array_test.c:70:5: 
68.   static int test_sparse_array_num(void)
69.   {
70. >     static const struct {
71.           size_t num;
72.           ossl_uintmax_t n;

test/sparse_array_test.c:80:5: 
78.           { 1, 1021, NULL }, { 0, 64000, NULL }, { 1, 23, "h" }, { 0, 23, NULL }
79.       };
80. >     SPARSE_ARRAY_OF(char) *sa = NULL;
81.       size_t i;
82.       int res = 0;

test/sparse_array_test.c:82:5: 
80.       SPARSE_ARRAY_OF(char) *sa = NULL;
81.       size_t i;
82. >     int res = 0;
83.   
84.       if (!TEST_size_t_eq(ossl_sa_char_num(NULL), 0)

test/sparse_array_test.c:84:10: 
82.       int res = 0;
83.   
84. >     if (!TEST_size_t_eq(ossl_sa_char_num(NULL), 0)
85.               || !TEST_ptr(sa = ossl_sa_char_new())
86.               || !TEST_size_t_eq(ossl_sa_char_num(sa), 0))

test/sparse_array_test.c:28:1: start of procedure ossl_sa_char_num()
  26.   #endif
  27.   
  28. > DEFINE_SPARSE_ARRAY_OF(char);
  29.   
  30.   static int test_sparse_array(void)

crypto/sparse_array.c:155:1: start of procedure OPENSSL_SA_num()
    153.   }
    154.   
    155. > size_t OPENSSL_SA_num(const OPENSSL_SA *sa)
    156.   {
    157.       return sa == NULL ? 0 : sa->nelem;

crypto/sparse_array.c:157:12: Condition is true
    155.   size_t OPENSSL_SA_num(const OPENSSL_SA *sa)
    156.   {
    157.       return sa == NULL ? 0 : sa->nelem;
                      ^
    158.   }
    159.   

crypto/sparse_array.c:157:5: 
    155.   size_t OPENSSL_SA_num(const OPENSSL_SA *sa)
    156.   {
    157. >     return sa == NULL ? 0 : sa->nelem;
    158.   }
    159.   

crypto/sparse_array.c:158:1: return from a call to OPENSSL_SA_num
    156.   {
    157.       return sa == NULL ? 0 : sa->nelem;
    158. > }
    159.   
    160.   void *OPENSSL_SA_get(const OPENSSL_SA *sa, ossl_uintmax_t n)

test/sparse_array_test.c:28:1: return from a call to ossl_sa_char_num
  26.   #endif
  27.   
  28. > DEFINE_SPARSE_ARRAY_OF(char);
  29.   
  30.   static int test_sparse_array(void)

test/testutil/tests.c:215:1: start of procedure test_size_t_eq()
  213.   DEFINE_COMPARISONS(long, long, "%ld")
  214.   DEFINE_COMPARISONS(unsigned long, ulong, "%lu")
  215. > DEFINE_COMPARISONS(size_t, size_t, "%zu")
  216.   DEFINE_COMPARISONS(double, double, "%g")
  217.   

test/testutil/tests.c:215:1: Taking true branch
  213.   DEFINE_COMPARISONS(long, long, "%ld")
  214.   DEFINE_COMPARISONS(unsigned long, ulong, "%lu")
  215. > DEFINE_COMPARISONS(size_t, size_t, "%zu")
  216.   DEFINE_COMPARISONS(double, double, "%g")
  217.   

test/testutil/tests.c:215:1: return from a call to test_size_t_eq
  213.   DEFINE_COMPARISONS(long, long, "%ld")
  214.   DEFINE_COMPARISONS(unsigned long, ulong, "%lu")
  215. > DEFINE_COMPARISONS(size_t, size_t, "%zu")
  216.   DEFINE_COMPARISONS(double, double, "%g")
  217.   

test/sparse_array_test.c:84:10: Taking false branch
82.       int res = 0;
83.   
84.       if (!TEST_size_t_eq(ossl_sa_char_num(NULL), 0)
               ^
85.               || !TEST_ptr(sa = ossl_sa_char_new())
86.               || !TEST_size_t_eq(ossl_sa_char_num(sa), 0))

test/sparse_array_test.c:85:17: 
83.   
84.       if (!TEST_size_t_eq(ossl_sa_char_num(NULL), 0)
85. >             || !TEST_ptr(sa = ossl_sa_char_new())
86.               || !TEST_size_t_eq(ossl_sa_char_num(sa), 0))
87.           goto err;

test/sparse_array_test.c:28:1: start of procedure ossl_sa_char_new()
  26.   #endif
  27.   
  28. > DEFINE_SPARSE_ARRAY_OF(char);
  29.   
  30.   static int test_sparse_array(void)

crypto/sparse_array.c:63:1: start of procedure OPENSSL_SA_new()
    61.   };
    62.   
    63. > OPENSSL_SA *OPENSSL_SA_new(void)
    64.   {
    65.       OPENSSL_SA *res = OPENSSL_zalloc(sizeof(*res));

crypto/sparse_array.c:65:5: 
    63.   OPENSSL_SA *OPENSSL_SA_new(void)
    64.   {
    65. >     OPENSSL_SA *res = OPENSSL_zalloc(sizeof(*res));
    66.   
    67.       return res;

crypto/mem.c:228:1: start of procedure CRYPTO_zalloc()
      226.   }
      227.   
      228. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
      229.   {
      230.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:230:5: 
      228.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
      229.   {
      230. >     void *ret = CRYPTO_malloc(num, file, line);
      231.   
      232.       FAILTEST();

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

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

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

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

crypto/mem.c:204:9: Taking true branch
        202.   
        203.       FAILTEST();
        204.       if (allow_customize) {
                       ^
        205.           /*
        206.            * Disallow customization after the first allocation. We only set this

crypto/mem.c:210:9: 
        208.            * allocation.
        209.            */
        210. >         allow_customize = 0;
        211.       }
        212.   #if !defined(OPENSSL_NO_CRYPTO_MDEBUG) && !defined(FIPS_MODE)

crypto/mem.c:221:5: 
        219.       }
        220.   #else
        221. >     (void)(file); (void)(line);
        222.       ret = malloc(num);
        223.   #endif

crypto/mem.c:221:19: 
        219.       }
        220.   #else
        221. >     (void)(file); (void)(line);
        222.       ret = malloc(num);
        223.   #endif

crypto/mem.c:222:5: 
        220.   #else
        221.       (void)(file); (void)(line);
        222. >     ret = malloc(num);
        223.   #endif
        224.   

crypto/mem.c:225:5: 
        223.   #endif
        224.   
        225. >     return ret;
        226.   }
        227.   

crypto/mem.c:226:1: return from a call to CRYPTO_malloc
        224.   
        225.       return ret;
        226. > }
        227.   
        228.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:233:9: Taking true branch
      231.   
      232.       FAILTEST();
      233.       if (ret != NULL)
                     ^
      234.           memset(ret, 0, num);
      235.       return ret;

crypto/mem.c:234:9: 
      232.       FAILTEST();
      233.       if (ret != NULL)
      234. >         memset(ret, 0, num);
      235.       return ret;
      236.   }

crypto/mem.c:235:5: 
      233.       if (ret != NULL)
      234.           memset(ret, 0, num);
      235. >     return ret;
      236.   }
      237.   

crypto/mem.c:236:1: return from a call to CRYPTO_zalloc
      234.           memset(ret, 0, num);
      235.       return ret;
      236. > }
      237.   
      238.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/sparse_array.c:67:5: 
    65.       OPENSSL_SA *res = OPENSSL_zalloc(sizeof(*res));
    66.   
    67. >     return res;
    68.   }
    69.   

crypto/sparse_array.c:68:1: return from a call to OPENSSL_SA_new
    66.   
    67.       return res;
    68. > }
    69.   
    70.   static void sa_doall(const OPENSSL_SA *sa, void (*node)(void **),

test/sparse_array_test.c:28:1: return from a call to ossl_sa_char_new
  26.   #endif
  27.   
  28. > DEFINE_SPARSE_ARRAY_OF(char);
  29.   
  30.   static int test_sparse_array(void)

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

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

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

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

test/sparse_array_test.c:85:17: Taking false branch
83.   
84.       if (!TEST_size_t_eq(ossl_sa_char_num(NULL), 0)
85.               || !TEST_ptr(sa = ossl_sa_char_new())
                      ^
86.               || !TEST_size_t_eq(ossl_sa_char_num(sa), 0))
87.           goto err;

test/sparse_array_test.c:86:17: 
84.       if (!TEST_size_t_eq(ossl_sa_char_num(NULL), 0)
85.               || !TEST_ptr(sa = ossl_sa_char_new())
86. >             || !TEST_size_t_eq(ossl_sa_char_num(sa), 0))
87.           goto err;
88.       for (i = 0; i < OSSL_NELEM(cases); i++)

test/sparse_array_test.c:28:1: start of procedure ossl_sa_char_num()
  26.   #endif
  27.   
  28. > DEFINE_SPARSE_ARRAY_OF(char);
  29.   
  30.   static int test_sparse_array(void)

crypto/sparse_array.c:155:1: start of procedure OPENSSL_SA_num()
    153.   }
    154.   
    155. > size_t OPENSSL_SA_num(const OPENSSL_SA *sa)
    156.   {
    157.       return sa == NULL ? 0 : sa->nelem;

crypto/sparse_array.c:157:12: Condition is false
    155.   size_t OPENSSL_SA_num(const OPENSSL_SA *sa)
    156.   {
    157.       return sa == NULL ? 0 : sa->nelem;
                      ^
    158.   }
    159.   

crypto/sparse_array.c:157:5: 
    155.   size_t OPENSSL_SA_num(const OPENSSL_SA *sa)
    156.   {
    157. >     return sa == NULL ? 0 : sa->nelem;
    158.   }
    159.   

crypto/sparse_array.c:158:1: return from a call to OPENSSL_SA_num
    156.   {
    157.       return sa == NULL ? 0 : sa->nelem;
    158. > }
    159.   
    160.   void *OPENSSL_SA_get(const OPENSSL_SA *sa, ossl_uintmax_t n)

test/sparse_array_test.c:28:1: return from a call to ossl_sa_char_num
  26.   #endif
  27.   
  28. > DEFINE_SPARSE_ARRAY_OF(char);
  29.   
  30.   static int test_sparse_array(void)

test/testutil/tests.c:215:1: start of procedure test_size_t_eq()
  213.   DEFINE_COMPARISONS(long, long, "%ld")
  214.   DEFINE_COMPARISONS(unsigned long, ulong, "%lu")
  215. > DEFINE_COMPARISONS(size_t, size_t, "%zu")
  216.   DEFINE_COMPARISONS(double, double, "%g")
  217.   

test/testutil/tests.c:215:1: Taking false branch
  213.   DEFINE_COMPARISONS(long, long, "%ld")
  214.   DEFINE_COMPARISONS(unsigned long, ulong, "%lu")
  215. > DEFINE_COMPARISONS(size_t, size_t, "%zu")
  216.   DEFINE_COMPARISONS(double, double, "%g")
  217.   

test/testutil/tests.c:215:1: return from a call to test_size_t_eq
  213.   DEFINE_COMPARISONS(long, long, "%ld")
  214.   DEFINE_COMPARISONS(unsigned long, ulong, "%lu")
  215. > DEFINE_COMPARISONS(size_t, size_t, "%zu")
  216.   DEFINE_COMPARISONS(double, double, "%g")
  217.   

test/sparse_array_test.c:86:17: Taking true branch
84.       if (!TEST_size_t_eq(ossl_sa_char_num(NULL), 0)
85.               || !TEST_ptr(sa = ossl_sa_char_new())
86.               || !TEST_size_t_eq(ossl_sa_char_num(sa), 0))
                      ^
87.           goto err;
88.       for (i = 0; i < OSSL_NELEM(cases); i++)

test/sparse_array_test.c:93:1: 
91.               goto err;
92.       res = 1;
93. > err:
94.       ossl_sa_char_free(sa);
95.       return res;

test/sparse_array_test.c:94:5: 
92.       res = 1;
93.   err:
94. >     ossl_sa_char_free(sa);
95.       return res;
96.   }

test/sparse_array_test.c:28:1: start of procedure ossl_sa_char_free()
  26.   #endif
  27.   
  28. > DEFINE_SPARSE_ARRAY_OF(char);
  29.   
  30.   static int test_sparse_array(void)

crypto/sparse_array.c:115:1: start of procedure OPENSSL_SA_free()
    113.   }
    114.   
    115. > void OPENSSL_SA_free(OPENSSL_SA *sa)
    116.   {
    117.       sa_doall(sa, &sa_free_node, NULL, NULL);

crypto/sparse_array.c:117:5: Skipping sa_doall(): empty list of specs
    115.   void OPENSSL_SA_free(OPENSSL_SA *sa)
    116.   {
    117.       sa_doall(sa, &sa_free_node, NULL, NULL);
               ^
    118.       OPENSSL_free(sa);
    119.   }

crypto/sparse_array.c:118:5: 
    116.   {
    117.       sa_doall(sa, &sa_free_node, NULL, NULL);
    118. >     OPENSSL_free(sa);
    119.   }
    120.   

crypto/mem.c:295:1: start of procedure CRYPTO_free()
      293.   }
      294.   
      295. > void CRYPTO_free(void *str, const char *file, int line)
      296.   {
      297.       INCREMENT(free_count);

crypto/mem.c:298:9: Taking true branch
      296.   {
      297.       INCREMENT(free_count);
      298.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                     ^
      299.           free_impl(str, file, line);
      300.           return;

crypto/mem.c:298:30: Taking true branch
      296.   {
      297.       INCREMENT(free_count);
      298.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                                          ^
      299.           free_impl(str, file, line);
      300.           return;

crypto/mem.c:299:9: Skipping __function_pointer__(): unresolved function pointer
      297.       INCREMENT(free_count);
      298.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
      299.           free_impl(str, file, line);
                     ^
      300.           return;
      301.       }

crypto/mem.c:300:9: 
      298.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
      299.           free_impl(str, file, line);
      300. >         return;
      301.       }
      302.   

crypto/mem.c:314:1: return from a call to CRYPTO_free
      312.       free(str);
      313.   #endif
      314. > }
      315.   
      316.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

crypto/sparse_array.c:119:1: return from a call to OPENSSL_SA_free
    117.       sa_doall(sa, &sa_free_node, NULL, NULL);
    118.       OPENSSL_free(sa);
    119. > }
    120.   
    121.   void OPENSSL_SA_free_leaves(OPENSSL_SA *sa)

test/sparse_array_test.c:28:1: return from a call to ossl_sa_char_free
  26.   #endif
  27.   
  28. > DEFINE_SPARSE_ARRAY_OF(char);
  29.   
  30.   static int test_sparse_array(void)

static int test_sparse_array_num(void)
{
    static const struct {
        size_t num;
        ossl_uintmax_t n;
        char *v;
    } cases[] = {
        { 1, 22, "a" }, { 2, 1021, "b" }, { 3, 3, "c" }, { 2, 22, NULL },
        { 2, 3, "d" }, { 3, 22, "e" }, { 3, 666, NULL }, { 4, 666, "f" },
        { 3, 3, NULL }, { 2, 22, NULL }, { 1, 666, NULL }, { 2, 64000, "g" },
        { 1, 1021, NULL }, { 0, 64000, NULL }, { 1, 23, "h" }, { 0, 23, NULL }
    };
    SPARSE_ARRAY_OF(char) *sa = NULL;
    size_t i;
    int res = 0;
    if (!TEST_size_t_eq(ossl_sa_char_num(NULL), 0)
            || !TEST_ptr(sa = ossl_sa_char_new())
            || !TEST_size_t_eq(ossl_sa_char_num(sa), 0))
        goto err;
    for (i = 0; i < OSSL_NELEM(cases); i++)
        if (!TEST_true(ossl_sa_char_set(sa, cases[i].n, cases[i].v))
                || !TEST_size_t_eq(ossl_sa_char_num(sa), cases[i].num))
            goto err;
    res = 1;
err:
    ossl_sa_char_free(sa);
    return res;
}
['static int test_sparse_array_num(void)\n{\n    static const struct {\n        size_t num;\n        ossl_uintmax_t n;\n        char *v;\n    } cases[] = {\n        { 1, 22, "a" }, { 2, 1021, "b" }, { 3, 3, "c" }, { 2, 22, NULL },\n        { 2, 3, "d" }, { 3, 22, "e" }, { 3, 666, NULL }, { 4, 666, "f" },\n        { 3, 3, NULL }, { 2, 22, NULL }, { 1, 666, NULL }, { 2, 64000, "g" },\n        { 1, 1021, NULL }, { 0, 64000, NULL }, { 1, 23, "h" }, { 0, 23, NULL }\n    };\n    SPARSE_ARRAY_OF(char) *sa = NULL;\n    size_t i;\n    int res = 0;\n    if (!TEST_size_t_eq(ossl_sa_char_num(NULL), 0)\n            || !TEST_ptr(sa = ossl_sa_char_new())\n            || !TEST_size_t_eq(ossl_sa_char_num(sa), 0))\n        goto err;\n    for (i = 0; i < OSSL_NELEM(cases); i++)\n        if (!TEST_true(ossl_sa_char_set(sa, cases[i].n, cases[i].v))\n                || !TEST_size_t_eq(ossl_sa_char_num(sa), cases[i].num))\n            goto err;\n    res = 1;\nerr:\n    ossl_sa_char_free(sa);\n    return res;\n}', 'DEFINE_SPARSE_ARRAY_OF(char)', 'size_t OPENSSL_SA_num(const OPENSSL_SA *sa)\n{\n    return sa == NULL ? 0 : sa->nelem;\n}', 'DEFINE_COMPARISONS(size_t, size_t, "%zu")', 'OPENSSL_SA *OPENSSL_SA_new(void)\n{\n    OPENSSL_SA *res = OPENSSL_zalloc(sizeof(*res));\n    return res;\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    if (allow_customize) {\n        allow_customize = 0;\n    }\n#if !defined(OPENSSL_NO_CRYPTO_MDEBUG) && !defined(FIPS_MODE)\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}', 'void OPENSSL_SA_free(OPENSSL_SA *sa)\n{\n    sa_doall(sa, &sa_free_node, NULL, NULL);\n    OPENSSL_free(sa);\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#if !defined(OPENSSL_NO_CRYPTO_MDEBUG) && !defined(FIPS_MODE)\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}']