1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-30 04:10:54 -08:00

Fix an off-by-one error in TEX parsing in etags

* lib-src/etags.c (TEX_decode_env): Fix off-by-one parsing of
TEXTAGS environment variable (bug#52438).  Based on a patch by
David Fussner <dfussner@googlemail.com> and amended by Andreas
Schwab <schwab@linux-m68k.org>.
This commit is contained in:
Lars Ingebrigtsen 2021-12-12 11:26:22 +01:00
parent 6c9adafa93
commit bdfd83e42d

View file

@ -5773,7 +5773,7 @@ static void
TEX_decode_env (const char *evarname, const char *defenv)
{
const char *env, *p;
ptrdiff_t len;
ptrdiff_t len = 1;
/* Append default string to environment. */
env = getenv (evarname);
@ -5782,8 +5782,13 @@ TEX_decode_env (const char *evarname, const char *defenv)
else
env = concat (env, defenv, "");
/* If the environment variable starts with a colon, increase the
length of the token table. */
if (*env == ':')
len++;
/* Allocate a token table */
for (len = 1, p = env; (p = strchr (p, ':')); )
for (p = env; (p = strchr (p, ':')); )
if (*++p)
len++;
TEX_toktab = xnew (len, linebuffer);