all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Eli Zaretskii <eliz@gnu.org>
Cc: p.stephani2@gmail.com, johnw@gnu.org, schwab@linux-m68k.org,
	nicolas@petton.fr, 24206@debbugs.gnu.org
Subject: bug#24206: 25.1; Curly quotes generate invalid strings, leading to a segfault
Date: Tue, 16 Aug 2016 10:37:39 -0700	[thread overview]
Message-ID: <17f39e7e-31d1-62e5-367d-833b957a39e3@cs.ucla.edu> (raw)
In-Reply-To: <83eg5og4n9.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 602 bytes --]

Eli Zaretskii wrote:

> I preferred to install one of the 2 patches I posted yesterday.

Let's not cut the RC now, as unfortunately that patch fails spectacularly. (I 
didn't test it yesterday; I tested your other patch, which is obviously better.) 
To reproduce the problem, run emacs -Q and "C-h f car RET"; Emacs will display 
"Wrong type argument: integer-or-marker-p, nil" instead of help.

The attached patch to emacs-25 fixes the problem. It makes the code functionally 
equivalent to the other of the 2 patches that you posted yesterday, and is 
simpler. OK to install in emacs-25?

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-wrong-type-argument-bug-with-C-h-f.patch --]
[-- Type: text/x-diff; name="0001-Fix-wrong-type-argument-bug-with-C-h-f.patch", Size: 2752 bytes --]

From 36a8eec4e8f07724e5ed202b0c68233019975e85 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Tue, 16 Aug 2016 10:36:14 -0700
Subject: [PATCH] =?UTF-8?q?Fix=20=E2=80=98wrong=20type=20argument=E2=80=99?=
 =?UTF-8?q?=20bug=20with=20C-h=20f?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* src/doc.c (Fsubstitute_command_keys): Revert previous change.
Instead, to fix the core dump, first convert source string to a
multibyte temporary if it is not multibyte already.  As before,
keep the original string if there are no changes (Bug#24206).
---
 src/doc.c | 24 +++++++-----------------
 1 file changed, 7 insertions(+), 17 deletions(-)

diff --git a/src/doc.c b/src/doc.c
index 86e1e0d..4f5f7a4 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -750,7 +750,7 @@ Otherwise, return a new string.  */)
   unsigned char const *start;
   ptrdiff_t length, length_byte;
   Lisp_Object name;
-  bool multibyte, pure_ascii;
+  bool multibyte;
   ptrdiff_t nchars;
 
   if (NILP (string))
@@ -763,12 +763,9 @@ Otherwise, return a new string.  */)
 
   enum text_quoting_style quoting_style = text_quoting_style ();
 
+  Lisp_Object orig_string = string;
+  string = Fstring_make_multibyte (string);
   multibyte = STRING_MULTIBYTE (string);
-  /* Pure-ASCII unibyte input strings should produce unibyte strings
-     if substitution doesn't yield non-ASCII bytes, otherwise they
-     should produce multibyte strings.  */
-  pure_ascii = SBYTES (string) == count_size_as_multibyte (SDATA (string),
-							   SCHARS (string));
   nchars = 0;
 
   /* KEYMAP is either nil (which means search all the active keymaps)
@@ -950,11 +947,8 @@ Otherwise, return a new string.  */)
 
 	subst_string:
 	  start = SDATA (tem);
+	  length = SCHARS (tem);
 	  length_byte = SBYTES (tem);
-	  if (multibyte || pure_ascii)
-	    length = SCHARS (tem);
-	  else
-	    length = length_byte;
 	subst:
 	  nonquotes_changed = true;
 	subst_quote:
@@ -973,15 +967,11 @@ Otherwise, return a new string.  */)
 	  }
 	}
       else if ((strp[0] == '`' || strp[0] == '\'')
-	       && quoting_style == CURVE_QUOTING_STYLE
-	       && multibyte)
+	       && quoting_style == CURVE_QUOTING_STYLE)
 	{
 	  start = (unsigned char const *) (strp[0] == '`' ? uLSQM : uRSQM);
+	  length = 1;
 	  length_byte = sizeof uLSQM - 1;
-	  if (multibyte || pure_ascii)
-	    length = 1;
-	  else
-	    length = length_byte;
 	  idx = strp - SDATA (string) + 1;
 	  goto subst_quote;
 	}
@@ -1036,7 +1026,7 @@ Otherwise, return a new string.  */)
 	}
     }
   else
-    tem = string;
+    tem = orig_string;
   xfree (buf);
   return tem;
 }
-- 
2.5.5


  parent reply	other threads:[~2016-08-16 17:37 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-11 18:55 bug#24206: 25.1; Curly quotes generate invalid strings, leading to a segfault Phil
2016-08-11 20:05 ` Eli Zaretskii
2016-08-11 23:51   ` Philipp Stephani
2016-08-13  8:32     ` Eli Zaretskii
2016-08-13 12:25       ` Nicolas Petton
2016-08-14  6:33         ` John Wiegley
2016-08-14  4:54 ` Paul Eggert
2016-08-14 14:27   ` Eli Zaretskii
2016-08-14 14:51     ` Paul Eggert
2016-08-14 17:18       ` Eli Zaretskii
2016-08-15  2:04         ` Paul Eggert
2016-08-15 16:09           ` Eli Zaretskii
2016-08-15 16:46             ` Andreas Schwab
2016-08-15 18:43               ` Paul Eggert
2016-08-15 19:04                 ` Eli Zaretskii
2016-08-15 18:51               ` Eli Zaretskii
2016-08-15 19:05                 ` John Wiegley
2016-08-15 20:41                 ` Paul Eggert
2016-08-16 14:38                   ` Eli Zaretskii
2016-08-16 15:25                     ` John Wiegley
2016-08-16 16:09                       ` Nicolas Petton
2016-08-18 16:30                       ` Nicolas Petton
2016-08-18 16:41                         ` John Wiegley
2016-08-18 17:35                           ` Eli Zaretskii
2016-08-16 17:37                     ` Paul Eggert [this message]
2016-08-16 17:45                       ` John Wiegley
2016-08-16 17:55                         ` Paul Eggert
2016-08-16 17:57                           ` John Wiegley
2016-08-16 18:44                           ` Dmitry Gutov
2016-08-16 18:31                       ` Eli Zaretskii
2016-08-16 14:52                   ` Eli Zaretskii
2016-08-16 21:07                     ` Paul Eggert
2016-08-17 15:12                       ` Eli Zaretskii
2016-08-17 17:41                         ` Paul Eggert
2016-08-17 18:06                           ` Eli Zaretskii
2016-08-17 20:52                             ` Paul Eggert
2016-08-18 14:30                               ` Eli Zaretskii
2016-08-18 18:33                                 ` Paul Eggert
2016-08-18 18:58                                   ` Eli Zaretskii
2016-08-17 17:50                       ` Dmitry Gutov
2016-08-14 15:21   ` Dmitry Gutov
2016-08-15  1:53     ` Paul Eggert
2016-08-15  1:57       ` Dmitry Gutov
2016-08-15  2:05         ` Paul Eggert
2016-08-14 17:21   ` Eli Zaretskii
2016-08-14 20:16     ` Paul Eggert
2016-08-15  1:12       ` Paul Eggert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=17f39e7e-31d1-62e5-367d-833b957a39e3@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=24206@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=johnw@gnu.org \
    --cc=nicolas@petton.fr \
    --cc=p.stephani2@gmail.com \
    --cc=schwab@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.