Don't display empty error context.

Context extraction didn't handle this case and showed uninitialized memory.

Obtained from: OpenBSD lib.c 1.21
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D12379
This commit is contained in:
Warner Losh 2017-09-24 05:04:06 +00:00
parent 8e537f8ae0
commit d12420d872

View File

@ -617,7 +617,7 @@ void eprint(void) /* try to print context around error */
static int been_here = 0;
extern char ebuf[], *ep;
if (compile_time == 2 || compile_time == 0 || been_here++ > 0)
if (compile_time == 2 || compile_time == 0 || been_here++ > 0 || ebuf == ep)
return;
p = ep - 1;
if (p > ebuf && *p == '\n')