Subject: bug#24206: 25.1; Curly quotes generate invalid strings, leading to a segfault

From: Eli Zaretskii <[email-masked]>
Date: Sun, 14 Aug 2016 20:21:43 +0300

> Cc: [email-masked], Eli Zaretskii <[email-masked]>,
>  John Wiegley <[email-masked]>, Nicolas Petton <[email-masked]>
> From: Paul Eggert <[email-masked]>
> Date: Sat, 13 Aug 2016 23:54:43 -0500
> 
> For Emacs 25 I propose installing the attached patch, which should avoid 
> the emacs-goodies-el problem though it does not fix the other 
> (presumably less-likely) bugs in this area. This patch is considerably 
> simpler than what I just installed into master.

Paul, would you agree with the following alternative patch for the
release branch?

Phil, is the recipe you presented in this bug _exactly_ what
emacs-goodies-el does?  If not, could you please see if the proposed
patch below fixes the real-life use case as well, and if not, show
that use case?  TIA.

diff --git a/src/doc.c b/src/doc.c
index 7cdb0d0..bba30b4 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -965,7 +965,8 @@ Otherwise, return a new string.  */)
 	  }
 	}
       else if ((strp[0] == '`' || strp[0] == '\'')
-	       && quoting_style == CURVE_QUOTING_STYLE)
+	       && quoting_style == CURVE_QUOTING_STYLE
+	       && multibyte)
 	{
 	  start = (unsigned char const *) (strp[0] == '`' ? uLSQM : uRSQM);
 	  length = 1;