From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Federico Tedin Newsgroups: gmane.emacs.bugs Subject: bug#40000: 27.0.60; next-single-char-property-change hangs on bad argument Date: Tue, 14 Apr 2020 23:05:35 +0200 Message-ID: <87v9m1dbhc.fsf@gmail.com> References: <87d08b333i.fsf@gmail.com> <83tv1niira.fsf@gnu.org> <878siz31ta.fsf@gmail.com> <83sgh7ihj2.fsf@gnu.org> <874ktn2yph.fsf@gmail.com> <83pncbidov.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="76033"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) Cc: casouri@gmail.com, 40000@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Apr 14 23:06:53 2020 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 1jOSlh-000JiN-BE for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 14 Apr 2020 23:06:53 +0200 Original-Received: from localhost ([::1]:39150 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jOSlg-0005DR-8P for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 14 Apr 2020 17:06:52 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55083) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jOSkv-0004ki-Ba for bug-gnu-emacs@gnu.org; Tue, 14 Apr 2020 17:06:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jOSkt-00039W-0p for bug-gnu-emacs@gnu.org; Tue, 14 Apr 2020 17:06:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:51583) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jOSks-000394-LO for bug-gnu-emacs@gnu.org; Tue, 14 Apr 2020 17:06:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jOSks-0005hV-F5 for bug-gnu-emacs@gnu.org; Tue, 14 Apr 2020 17:06:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Federico Tedin Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 14 Apr 2020 21:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 40000 X-GNU-PR-Package: emacs Original-Received: via spool by 40000-submit@debbugs.gnu.org id=B40000.158689834621892 (code B ref 40000); Tue, 14 Apr 2020 21:06:02 +0000 Original-Received: (at 40000) by debbugs.gnu.org; 14 Apr 2020 21:05:46 +0000 Original-Received: from localhost ([127.0.0.1]:34896 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jOSkc-0005h2-7b for submit@debbugs.gnu.org; Tue, 14 Apr 2020 17:05:46 -0400 Original-Received: from mail-wr1-f52.google.com ([209.85.221.52]:35899) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jOSka-0005gi-C3 for 40000@debbugs.gnu.org; Tue, 14 Apr 2020 17:05:44 -0400 Original-Received: by mail-wr1-f52.google.com with SMTP id u13so15755260wrp.3 for <40000@debbugs.gnu.org>; Tue, 14 Apr 2020 14:05:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=GloyQzfUzd1/nleBvZboc5e9s8TVapbXNojEPBUlPlM=; b=JmvWess1XPTMExSe0REibtSy1xcTuv98WNRlBxJG0vHL2N5ympxTpyaFBPvIHolTiW j4nBbIngGOe7CzRD0CBJeEPVtO4JX6nxgpovneKIovsa9X+5bNSprU6rlOq3AwqKRGiX Gk8OcWgCcbK6OSGgiG+yhVGfFqKjgYJzmDJ/TOCIgx7VhbMnyh5D2KCEDLqV9JEdSO8o HWDQAFfV85eyFqqdPsf1jux+NGXzGjan89DxA90z9eosxzfKh3+Q/3d9uQPnauNIdc6t Zv4CRrfr6cX6BJ1SNWgSDadHYspMb/YyCZQJzz47qvLwO2LgAm1Gu/e9ZTg4P+HMIDJv D0RA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=GloyQzfUzd1/nleBvZboc5e9s8TVapbXNojEPBUlPlM=; b=OoJeoUm8+xlayRx16NZGmhaecWd7DxPeEqfN1/4Y36uAIsMj7NBGkzVpW11OUjeKPe VL1w3apz338A8Dif5USiKYJovmOl5/DpxW+qXqvH8ohXoXgmszhMnmsEltRHTyqdKO75 sno1ZDXtMwXkis1M71f/K0uC0qt1qcyCrdxJjNovzs0q2Am4h6+vNU4U4bZol6SHcW7w O3c9R/PJoJEx5dYcF+uzw9wZCE2poNK0edkdxyFUIDL36nlznhTictOHqNWWTgyrWWug NFc6M/9kg+CPREn2O5QlXGA7vIKcZbIJqH4D8qmhxWHKYFhlePxZ+hpH7wzXQycP55jl 6yog== X-Gm-Message-State: AGi0PuY0f/Y7MKcZUHLHHAHlOyzzs9C6i7hle9cq6EKrpHGmWWGnPJZF tPJo4kf4pj8CmLf9anUErNCYLkCXle0= X-Google-Smtp-Source: APiQypKcPXsQ2h8J9kBr47elXcq382b3TrRcx5Ef+QLciCWO2IxZwhXfWCmzgMLLDvlloTiIHvrFlA== X-Received: by 2002:adf:a704:: with SMTP id c4mr3081580wrd.303.1586898338126; Tue, 14 Apr 2020 14:05:38 -0700 (PDT) Original-Received: from lead ([2a02:8109:8ac0:2ff0:7077:607d:3f1f:454e]) by smtp.gmail.com with ESMTPSA id i129sm20922022wmi.20.2020.04.14.14.05.36 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 Apr 2020 14:05:36 -0700 (PDT) In-Reply-To: <83pncbidov.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 13 Apr 2020 18:54:24 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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:178376 Archived-At: --=-=-= Content-Type: text/plain > Then we'd need to clearly document the behavior in each case, I guess. Ok, I've taken another shot at it. I updated the function's documentation to reflect what happens with LIMIT when working on a string and on a buffer, hopefully it's clear enough. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Prevent-hanging-in-next-single-char-property-change.patch >From 972c1d0f2b479ba9f1ad5643ee9ce5d268077ace Mon Sep 17 00:00:00 2001 From: Federico Tedin Date: Tue, 14 Apr 2020 23:02:44 +0200 Subject: [PATCH] Prevent hanging in next-single-char-property-change * src/textprop.c (Fnext_single_char_property_change): Prevent Emacs from hanging when the value of LIMIT is greater than the buffer's end position. (Bug#40000) --- src/textprop.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/textprop.c b/src/textprop.c index 960dba3f8d..378c158875 100644 --- a/src/textprop.c +++ b/src/textprop.c @@ -765,15 +765,15 @@ DEFUN ("next-single-char-property-change", Fnext_single_char_property_change, the current buffer), POSITION is a buffer position (integer or marker). If OBJECT is a string, POSITION is a 0-based index into it. -In a string, scan runs to the end of the string, unless LIMIT is non-nil. -In a buffer, if LIMIT is nil or omitted, it runs to (point-max), and the -value cannot exceed that. -If the optional fourth argument LIMIT is non-nil, don't search -past position LIMIT; return LIMIT if nothing is found before LIMIT. +In a string, scan runs to the end of the string, unless LIMIT is +non-nil, in which case its value is returned if nothing is found +before it. -The property values are compared with `eq'. -If the property is constant all the way to the end of OBJECT, return the -last valid position in OBJECT. */) +In a buffer, if LIMIT is nil or omitted, it runs to (point-max). If +LIMIT is non-nil, scan does not go past it, and the smallest of +(point-max) and LIMIT is returned. + +The property values are compared with `eq'. */) (Lisp_Object position, Lisp_Object prop, Lisp_Object object, Lisp_Object limit) { if (STRINGP (object)) @@ -832,6 +832,12 @@ DEFUN ("next-single-char-property-change", Fnext_single_char_property_change, value = Fget_char_property (position, prop, object); if (!EQ (value, initial_value)) break; + + if (XFIXNAT (position) >= ZV) + { + XSETFASTINT (position, ZV); + break; + } } position = unbind_to (count, position); -- 2.17.1 --=-=-=--