From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#52438: 29.0.50; [PATCH] Fix off-by-one error in etags.c TeX support Date: Sun, 12 Dec 2021 06:41:43 +0100 Message-ID: <87lf0qfkh4.fsf@gnus.org> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20449"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: 52438@debbugs.gnu.org To: David Fussner Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Dec 12 06:42:19 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mwHcp-00058g-E3 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 12 Dec 2021 06:42:19 +0100 Original-Received: from localhost ([::1]:47256 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mwHcn-0005Z5-Mg for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 12 Dec 2021 00:42:17 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:45460) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mwHcZ-0005Yp-4H for bug-gnu-emacs@gnu.org; Sun, 12 Dec 2021 00:42:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:38925) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mwHcY-0006uY-Jm for bug-gnu-emacs@gnu.org; Sun, 12 Dec 2021 00:42:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mwHcY-00084i-Fi for bug-gnu-emacs@gnu.org; Sun, 12 Dec 2021 00:42:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 12 Dec 2021 05:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52438 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 52438-submit@debbugs.gnu.org id=B52438.163928772031020 (code B ref 52438); Sun, 12 Dec 2021 05:42:02 +0000 Original-Received: (at 52438) by debbugs.gnu.org; 12 Dec 2021 05:42:00 +0000 Original-Received: from localhost ([127.0.0.1]:50468 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mwHcV-00084G-O3 for submit@debbugs.gnu.org; Sun, 12 Dec 2021 00:41:59 -0500 Original-Received: from quimby.gnus.org ([95.216.78.240]:44962) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mwHcT-00083z-HN for 52438@debbugs.gnu.org; Sun, 12 Dec 2021 00:41:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=FZ/H3D0UaSBbP8XTP6ZKAzSKVAgjWjDHcv4zq48QSMw=; b=PH/ce1pikud7cCncHOGAHjf1yS QaTa3UHdv05ETfqThhxbg7gAWoBI/BZ5vanjA36EaT7ViPXX1Ay+F4ULDV0uSDjH6ZCWwXiiz7Viy G3pY+YBGVVsQTOlIFQsRoHgtkMpkU4Qb7ylnfKKhBSUMQWC+r1jBcJmH8kNAASOO6WiY=; Original-Received: from [84.212.220.105] (helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mwHcJ-0002IZ-GI; Sun, 12 Dec 2021 06:41:51 +0100 X-Now-Playing: The Lounge Lizards's _No Pain for Cakes_: "My Clown's On Fire" In-Reply-To: (David Fussner's message of "Sat, 11 Dec 2021 18:50:24 +0000") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:222169 Archived-At: David Fussner writes: > The etags program reliably crashes for me when running the test suite in > test/manual/etags, but you need to have a long-enough TEXTAGS > environment variable to make it happen. On my 32-bit GNU/Linux machine, > going to that directory and running: > > TEXTAGS="A:B:C:D:E:F:G:H:I:J:K:L:M:N:O:P:Q:R:S:T:U:V:W:X" make check > > crashes the program before it finishes the first run, that is, before it > stops because the test suite itself fails. I'm not able to reproduce the issue on my 64-bit Debian system, but reading the code, I think your analysis of the problem sounds correct. The patch seemed slightly confusing, though, so I rewrote it a bit. Could you check whether this version also fixes the problem? diff --git a/lib-src/etags.c b/lib-src/etags.c index bd4d4fcf53..ba66eeede4 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c @@ -5773,7 +5773,7 @@ TeX_commands (FILE *inf) 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 (!strneq (env, ":", 1)) + 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); -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no