test/bntest.c:2105: error: USE_AFTER_FREE
  call to `clearstanza()` eventually accesses memory that was invalidated by call to `free()` on line 2105 indirectly during the call to `clearstanza()`.
Showing all 16 steps of the trace


test/bntest.c:2098:5: invalidation part of the trace starts here
2096.   
2097.       /* Read test file. */
2098.       memset(&s, 0, sizeof(s));
            ^
2099.       while (!feof(fp) && readstanza(&s, &linesread)) {
2100.           if (s.numpairs == 0)

test/bntest.c:2098:5: variable `s` accessed here
  2096.   
  2097.       /* Read test file. */
  2098.       memset(&s, 0, sizeof(s));
              ^
  2099.       while (!feof(fp) && readstanza(&s, &linesread)) {
  2100.           if (s.numpairs == 0)

test/bntest.c:2105:9: when calling `clearstanza` here
  2103.               errcnt++;
  2104.           }
  2105.           clearstanza(&s);
                  ^
  2106.           s.start = linesread;
  2107.       }

test/bntest.c:2047:1: parameter `s` of clearstanza
    2045.   }
    2046.   
    2047. > static void clearstanza(STANZA *s)
    2048.   {
    2049.       PAIR *pp = s->pairs;

test/bntest.c:2049:5: assigned
    2047.   static void clearstanza(STANZA *s)
    2048.   {
    2049.       PAIR *pp = s->pairs;
                ^
    2050.       int i = s->numpairs;
    2051.       int start = s->start;

test/bntest.c:2054:9: when calling `CRYPTO_free` here
    2052.   
    2053.       for ( ; --i >= 0; pp++) {
    2054.           OPENSSL_free(pp->key);
                    ^
    2055.           OPENSSL_free(pp->value);
    2056.       }

crypto/mem.c:253:1: parameter `str` of CRYPTO_free
      251.   }
      252.   
      253. > void CRYPTO_free(void *str, const char *file, int line)
      254.   {
      255.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:269:5: was invalidated by call to `free()`
      267.       }
      268.   #else
      269.       free(str);
                 ^
      270.   #endif
      271.   }

test/bntest.c:2098:5: use-after-lifetime part of the trace starts here
2096.   
2097.       /* Read test file. */
2098.       memset(&s, 0, sizeof(s));
            ^
2099.       while (!feof(fp) && readstanza(&s, &linesread)) {
2100.           if (s.numpairs == 0)

test/bntest.c:2098:5: variable `s` accessed here
  2096.   
  2097.       /* Read test file. */
  2098.       memset(&s, 0, sizeof(s));
              ^
  2099.       while (!feof(fp) && readstanza(&s, &linesread)) {
  2100.           if (s.numpairs == 0)

test/bntest.c:2105:9: when calling `clearstanza` here
  2103.               errcnt++;
  2104.           }
  2105.           clearstanza(&s);
                  ^
  2106.           s.start = linesread;
  2107.       }

test/bntest.c:2047:1: parameter `s` of clearstanza
    2045.   }
    2046.   
    2047. > static void clearstanza(STANZA *s)
    2048.   {
    2049.       PAIR *pp = s->pairs;

test/bntest.c:2049:5: assigned
    2047.   static void clearstanza(STANZA *s)
    2048.   {
    2049.       PAIR *pp = s->pairs;
                ^
    2050.       int i = s->numpairs;
    2051.       int start = s->start;

test/bntest.c:2054:9: when calling `CRYPTO_free` here
    2052.   
    2053.       for ( ; --i >= 0; pp++) {
    2054.           OPENSSL_free(pp->key);
                    ^
    2055.           OPENSSL_free(pp->value);
    2056.       }

crypto/mem.c:253:1: parameter `str` of CRYPTO_free
      251.   }
      252.   
      253. > void CRYPTO_free(void *str, const char *file, int line)
      254.   {
      255.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:269:5: invalid access occurs here
      267.       }
      268.   #else
      269.       free(str);
                 ^
      270.   #endif
      271.   }
