From unknown Wed Sep 10 16:41:29 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#50764 <50764@debbugs.gnu.org> To: bug#50764 <50764@debbugs.gnu.org> Subject: Status: Fix (string-distance "" "") edge-case Reply-To: bug#50764 <50764@debbugs.gnu.org> Date: Wed, 10 Sep 2025 23:41:29 +0000 retitle 50764 Fix (string-distance "" "") edge-case reassign 50764 emacs submitter 50764 Philip Kaludercic severity 50764 normal tag 50764 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 23 12:16:54 2021 Received: (at submit) by debbugs.gnu.org; 23 Sep 2021 16:16:54 +0000 Received: from localhost ([127.0.0.1]:55651 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mTRP4-0003Ie-Dn for submit@debbugs.gnu.org; Thu, 23 Sep 2021 12:16:54 -0400 Received: from lists.gnu.org ([209.51.188.17]:42758) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mTRP1-0003Gi-Rn for submit@debbugs.gnu.org; Thu, 23 Sep 2021 12:16:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59520) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTROz-0006Gs-Lo for bug-gnu-emacs@gnu.org; Thu, 23 Sep 2021 12:16:51 -0400 Received: from mout01.posteo.de ([185.67.36.65]:33157) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTROx-0001g8-BI for bug-gnu-emacs@gnu.org; Thu, 23 Sep 2021 12:16:49 -0400 Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id 0E266240027 for ; Thu, 23 Sep 2021 18:16:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1632413804; bh=xawEspaOMFkiAWg/bocStiO1BxgzlCs2IraHiDYkzUA=; h=From:To:Subject:Autocrypt:Date:From; b=gSdX0X8o3WomCGZ6wpvydiz6qgb/dvReMx53xxmD7hXpCHmMmxCt9DU04Tim6CTZl edP0Pkwwawxzg+WI+HtPTllokL4WKEu6bzsUTseg892GHBOKSli/BNx4iWN6fLvyZf 6wqSkHUhCnqOA8Nb09NKRzNhnVJ3mxCws3ZpOnauQ9WpCLtelb6SCtOsXnaugb9qGd VA1k7sAT5L03wem6ZeKLaff8ncYKtN1fR3RCTuhGGs6jHt5ML0CABPybK92ucwKPfT y8Bz2c/2VaWPtDjCbaDorG9g1sJOsQON59b0ZNxMLiaLLaOizjEbdh90Gl+xddY+3Z 0QNrSLngmeK0g== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4HFgK74CPTz6tmF for ; Thu, 23 Sep 2021 18:16:43 +0200 (CEST) From: Philip Kaludercic To: bug-gnu-emacs@gnu.org Subject: Fix (string-distance "" "") edge-case Autocrypt: addr=philipk@posteo.net; prefer-encrypt=nopreference; keydata= mDMEYHHqUhYJKwYBBAHaRw8BAQdAp3GdmYJ6tm5McweY6dEvIYIiry+Oz9rU4MH6NHWK0Ee0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiQBBMWCAA4FiEEDM2H44ZoPt9Ms0eHtVrAHPRh1FwFAmBx6lICGwMFCwkIBwIGFQoJ CAsCBBYCAwECHgECF4AACgkQtVrAHPRh1FyTkgEAjlbGPxFchvMbxzAES3r8QLuZgCxeAXunM9gh io0ePtUBALVhh9G6wIoZhl0gUCbQpoN/UJHI08Gm1qDob5zDxnIHuDgEYHHqUhIKKwYBBAGXVQEF AQEHQNcRB+MUimTMqoxxMMUERpOR+Q4b1KgncDZkhrO2ql1tAwEIB4h4BBgWCAAgFiEEDM2H44Zo Pt9Ms0eHtVrAHPRh1FwFAmBx6lICGwwACgkQtVrAHPRh1Fw1JwD/Qo7kvtib8jy7puyWrSv0MeTS g8qIxgoRWJE/KKdkCLEA/jb9b9/g8nnX+UcwHf/4VfKsjExlnND3FrBviXUW6NcB Date: Thu, 23 Sep 2021 16:16:42 +0000 Message-ID: <8735pv6zdh.fsf@posteo.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.65; envelope-from=philipk@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --=-=-= Content-Type: text/plain Tags: patch string-distance appears to be using uninitialized memory, if the second argument is an empty string. This leads to the function occasionally generating random and meaningless results. This patch ensures that the entire memory is initialized before it is accessed, fixing the results for edge cases with empty strings. In GNU Emacs 28.0.50 (build 13, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw scroll bars) of 2021-09-23 built on icterid Repository revision: bb5d8582f75712c3610795aa5ead79600308f8bb Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12011000 System Description: Debian GNU/Linux 11 (bullseye) Configured using: 'configure LDFLAGS=-flto 'CFLAGS=-O2 -march=native -mtune=native -pipe' --with-native-compilation PKG_CONFIG_PATH=' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-Fix-string-distance-for-two-empty-strings.patch >From fbc62cb035fe2a674c9834c6bdcef5c5d2af85e2 Mon Sep 17 00:00:00 2001 From: Philip Kaludercic Date: Thu, 23 Sep 2021 18:12:41 +0200 Subject: [PATCH] Fix string-distance for two empty strings * fns.c (Fstring_distance): Avoid using uninitialized memory --- src/fns.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fns.c b/src/fns.c index 4e74589ef2..a72e41aee5 100644 --- a/src/fns.c +++ b/src/fns.c @@ -322,7 +322,7 @@ DEFUN ("string-distance", Fstring_distance, Sstring_distance, 2, 3, 0, USE_SAFE_ALLOCA; ptrdiff_t *column = SAFE_ALLOCA ((len1 + 1) * sizeof (ptrdiff_t)); - for (y = 1; y <= len1; y++) + for (y = 0; y <= len1; y++) column[y] = y; if (use_byte_compare) -- 2.30.2 --=-=-= Content-Type: text/plain -- Philip K. --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 23 13:12:45 2021 Received: (at 50764-done) by debbugs.gnu.org; 23 Sep 2021 17:12:45 +0000 Received: from localhost ([127.0.0.1]:55753 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mTSH7-0007sG-Lb for submit@debbugs.gnu.org; Thu, 23 Sep 2021 13:12:45 -0400 Received: from mail1439c50.megamailservers.eu ([91.136.14.39]:58176 helo=mail264c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mTSH2-0007ru-CD for 50764-done@debbugs.gnu.org; Thu, 23 Sep 2021 13:12:43 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1632417153; bh=6JfWLTUfCJEBL3maRmo4Y3/7Fl2Ikti5iYtXe1U9Xlg=; h=From:Subject:Date:Cc:To:From; b=S7wUh6WarEt8kCgRdE5HFy9ejbbBp4KsgMslHrF+MJGW2SLCKqgO2goV17Nw2UbiH UxiXYCrGuHJoUT9AxqFRhrgZ+/gz78WeJ1yMap6A/HPNkijePnFOvhxO8PEb5M1dv7 ogWHBJzkUNaHmTRLxHtK45ptvjAryW0WHfm9Z3t0= Feedback-ID: mattiase@acm.or Received: from stanniol.lan (c-b952e353.032-75-73746f71.bbcust.telenor.se [83.227.82.185]) (authenticated bits=0) by mail264c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 18NHCUYj024799; Thu, 23 Sep 2021 17:12:32 +0000 From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.21\)) Subject: bug#50764: Fix (string-distance "" "") edge-case Message-Id: Date: Thu, 23 Sep 2021 19:12:30 +0200 To: Philip Kaludercic X-Mailer: Apple Mail (2.3445.104.21) X-CTCH-RefID: str=0001.0A742F26.614CB581.000F, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.4 cv=HoQVp2fS c=1 sm=1 tr=0 ts=614cb581 a=von4qPfY+hyqc0zmWf0tYQ==:117 a=von4qPfY+hyqc0zmWf0tYQ==:17 a=kj9zAlcOel0A:10 a=M51BFTxLslgA:10 a=yXaGEri_KSclT5EP2qUA:9 a=CjuIK1q_8ugA:10 X-Origin-Country: SE X-Spam-Score: 1.4 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Looks like your independent test suite is already paying dividends! Pushed with tests. Content analysis details: (1.4 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.4 KHOP_HELO_FCRDNS Relay HELO differs from its IP's reverse DNS X-Debbugs-Envelope-To: 50764-done Cc: 50764-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Looks like your independent test suite is already paying dividends! Pushed with tests. From unknown Wed Sep 10 16:41:29 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 22 Oct 2021 11:24:08 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator