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


test/bntest.c:2113:5: invalidation part of the trace starts here
2111.   
2112.       /* Read test file. */
2113.       memset(&s, 0, sizeof(s));
            ^
2114.       while (!feof(fp) && readstanza(&s, &linesread)) {
2115.           if (s.numpairs == 0)

test/bntest.c:2113:5: variable `s` accessed here
  2111.   
  2112.       /* Read test file. */
  2113.       memset(&s, 0, sizeof(s));
              ^
  2114.       while (!feof(fp) && readstanza(&s, &linesread)) {
  2115.           if (s.numpairs == 0)

test/bntest.c:2122:9: when calling `clearstanza` here
  2120.               goto err;
  2121.           }
  2122.           clearstanza(&s);
                  ^
  2123.           s.start = linesread;
  2124.       }

test/bntest.c:2067:1: parameter `s` of clearstanza
    2065.   }
    2066.   
    2067. > static void clearstanza(STANZA *s)
    2068.   {
    2069.       PAIR *pp = s->pairs;

test/bntest.c:2069:5: assigned
    2067.   static void clearstanza(STANZA *s)
    2068.   {
    2069.       PAIR *pp = s->pairs;
                ^
    2070.       int i = s->numpairs;
    2071.       int start = s->start;

test/bntest.c:2074:9: when calling `CRYPTO_free` here
    2072.   
    2073.       for ( ; --i >= 0; pp++) {
    2074.           OPENSSL_free(pp->key);
                    ^
    2075.           OPENSSL_free(pp->value);
    2076.       }

crypto/mem.c:163:1: parameter `str` of CRYPTO_free
      161.   }
      162.   
      163. > void CRYPTO_free(void *str, const char *file, int line)
      164.   {
      165.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:179:5: was invalidated by call to `free()`
      177.       }
      178.   #else
      179.       free(str);
                 ^
      180.   #endif
      181.   }

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

test/bntest.c:2113:5: variable `s` accessed here
  2111.   
  2112.       /* Read test file. */
  2113.       memset(&s, 0, sizeof(s));
              ^
  2114.       while (!feof(fp) && readstanza(&s, &linesread)) {
  2115.           if (s.numpairs == 0)

test/bntest.c:2122:9: when calling `clearstanza` here
  2120.               goto err;
  2121.           }
  2122.           clearstanza(&s);
                  ^
  2123.           s.start = linesread;
  2124.       }

test/bntest.c:2067:1: parameter `s` of clearstanza
    2065.   }
    2066.   
    2067. > static void clearstanza(STANZA *s)
    2068.   {
    2069.       PAIR *pp = s->pairs;

test/bntest.c:2069:5: assigned
    2067.   static void clearstanza(STANZA *s)
    2068.   {
    2069.       PAIR *pp = s->pairs;
                ^
    2070.       int i = s->numpairs;
    2071.       int start = s->start;

test/bntest.c:2074:9: when calling `CRYPTO_free` here
    2072.   
    2073.       for ( ; --i >= 0; pp++) {
    2074.           OPENSSL_free(pp->key);
                    ^
    2075.           OPENSSL_free(pp->value);
    2076.       }

crypto/mem.c:163:1: parameter `str` of CRYPTO_free
      161.   }
      162.   
      163. > void CRYPTO_free(void *str, const char *file, int line)
      164.   {
      165.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:179:5: invalid access occurs here
      177.       }
      178.   #else
      179.       free(str);
                 ^
      180.   #endif
      181.   }
