indent(1): Avoid potential use-after-free.

last_bl is a char pointer that tracks the last blank character in a
comment, which is used for wrapping long comment lines. Since the
underlying array may be reallocated, make sure last_bl is up to date when
that happens.

Differential Revision: https://reviews.freebsd.org/D6966 (Partial)
Obtained from:	Piotr Stefaniak
This commit is contained in:
Pedro F. Giffuni 2016-07-29 16:14:03 +00:00
parent 19fe172ace
commit 11821cabe8

View File

@ -71,6 +71,7 @@ FILE *output; /* the output file */
if (combuf == NULL) \
err(1, NULL); \
e_com = combuf + (e_com-s_com) + 1; \
last_bl = combuf + (last_bl-s_com) + 1; \
l_com = combuf + nsize - 5; \
s_com = combuf + 1; \
}