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


test/bntest.c:2223:5: invalidation part of the trace starts here
2221.   
2222.       /* Read test file. */
2223.       memset(&s, 0, sizeof(s));
            ^
2224.       while (!feof(fp) && readstanza(&s, &linesread)) {
2225.           if (s.numpairs == 0)

test/bntest.c:2223:5: variable `s` accessed here
  2221.   
  2222.       /* Read test file. */
  2223.       memset(&s, 0, sizeof(s));
              ^
  2224.       while (!feof(fp) && readstanza(&s, &linesread)) {
  2225.           if (s.numpairs == 0)

test/bntest.c:2231:9: when calling `clearstanza` here
  2229.               errcnt++;
  2230.           }
  2231.           clearstanza(&s);
                  ^
  2232.           s.start = linesread;
  2233.       }

test/bntest.c:2177:1: parameter `s` of clearstanza
    2175.   }
    2176.   
    2177. > static void clearstanza(STANZA *s)
    2178.   {
    2179.       PAIR *pp = s->pairs;

test/bntest.c:2179:5: assigned
    2177.   static void clearstanza(STANZA *s)
    2178.   {
    2179.       PAIR *pp = s->pairs;
                ^
    2180.       int i = s->numpairs;
    2181.       int start = s->start;

test/bntest.c:2184:9: when calling `CRYPTO_free` here
    2182.   
    2183.       for ( ; --i >= 0; pp++) {
    2184.           OPENSSL_free(pp->key);
                    ^
    2185.           OPENSSL_free(pp->value);
    2186.       }

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:2223:5: use-after-lifetime part of the trace starts here
2221.   
2222.       /* Read test file. */
2223.       memset(&s, 0, sizeof(s));
            ^
2224.       while (!feof(fp) && readstanza(&s, &linesread)) {
2225.           if (s.numpairs == 0)

test/bntest.c:2223:5: variable `s` accessed here
  2221.   
  2222.       /* Read test file. */
  2223.       memset(&s, 0, sizeof(s));
              ^
  2224.       while (!feof(fp) && readstanza(&s, &linesread)) {
  2225.           if (s.numpairs == 0)

test/bntest.c:2231:9: when calling `clearstanza` here
  2229.               errcnt++;
  2230.           }
  2231.           clearstanza(&s);
                  ^
  2232.           s.start = linesread;
  2233.       }

test/bntest.c:2177:1: parameter `s` of clearstanza
    2175.   }
    2176.   
    2177. > static void clearstanza(STANZA *s)
    2178.   {
    2179.       PAIR *pp = s->pairs;

test/bntest.c:2179:5: assigned
    2177.   static void clearstanza(STANZA *s)
    2178.   {
    2179.       PAIR *pp = s->pairs;
                ^
    2180.       int i = s->numpairs;
    2181.       int start = s->start;

test/bntest.c:2184:9: when calling `CRYPTO_free` here
    2182.   
    2183.       for ( ; --i >= 0; pp++) {
    2184.           OPENSSL_free(pp->key);
                    ^
    2185.           OPENSSL_free(pp->value);
    2186.       }

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.   }
