aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorLars Ingebrigtsen2021-12-12 11:26:22 +0100
committerLars Ingebrigtsen2021-12-12 11:26:22 +0100
commitbdfd83e42d0044db7e99cec452427c0b76d46f20 (patch)
tree81e563dbcd79f877bb1b79ff659504e2ad42a688 /lib-src
parent6c9adafa93193a5f80d1254e04de478b145add89 (diff)
downloademacs-bdfd83e42d0044db7e99cec452427c0b76d46f20.tar.gz
emacs-bdfd83e42d0044db7e99cec452427c0b76d46f20.zip
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>.
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/etags.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib-src/etags.c b/lib-src/etags.c
index bd4d4fcf53a..af142b0b3d1 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -5773,7 +5773,7 @@ static void
5773TEX_decode_env (const char *evarname, const char *defenv) 5773TEX_decode_env (const char *evarname, const char *defenv)
5774{ 5774{
5775 const char *env, *p; 5775 const char *env, *p;
5776 ptrdiff_t len; 5776 ptrdiff_t len = 1;
5777 5777
5778 /* Append default string to environment. */ 5778 /* Append default string to environment. */
5779 env = getenv (evarname); 5779 env = getenv (evarname);
@@ -5782,8 +5782,13 @@ TEX_decode_env (const char *evarname, const char *defenv)
5782 else 5782 else
5783 env = concat (env, defenv, ""); 5783 env = concat (env, defenv, "");
5784 5784
5785 /* If the environment variable starts with a colon, increase the
5786 length of the token table. */
5787 if (*env == ':')
5788 len++;
5789
5785 /* Allocate a token table */ 5790 /* Allocate a token table */
5786 for (len = 1, p = env; (p = strchr (p, ':')); ) 5791 for (p = env; (p = strchr (p, ':')); )
5787 if (*++p) 5792 if (*++p)
5788 len++; 5793 len++;
5789 TEX_toktab = xnew (len, linebuffer); 5794 TEX_toktab = xnew (len, linebuffer);