Commit b07b7515 authored by Geoff Simmons's avatar Geoff Simmons

fix an off-by-one error for resizing the output buffer in FMT_Format()

parent ed34e282
......@@ -1488,8 +1488,9 @@ FMT_Format(tx_t *tx, size_t *curlen)
tx->state = TX_FORMATTING;
/* Start curlen at 1, because we'll be appending a NUL byte */
*p = '\0';
*curlen = 0;
*curlen = 1;
for (int i = 0; i < fmt.n; i++) {
char *s = NULL;
size_t len = 0;
......@@ -1511,6 +1512,7 @@ FMT_Format(tx_t *tx, size_t *curlen)
}
}
*p = '\0';
*curlen -= 1;
assert(tx->state == TX_FORMATTING);
tx->state = TX_WRITTEN;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment