summaryrefslogtreecommitdiff
path: root/src/editfns.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2017-10-06 10:32:46 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2017-10-06 10:33:53 -0700
commit9226cf325421a168b42bd27abf5e171e877b48b9 (patch)
tree4d36ec218d3f674f159bc9c7a7418975d4b1062c /src/editfns.c
parentfa92f0c44715fc49e19de001ee8b217ce847d954 (diff)
downloademacs-9226cf325421a168b42bd27abf5e171e877b48b9.tar.gz
emacs-9226cf325421a168b42bd27abf5e171e877b48b9.tar.bz2
emacs-9226cf325421a168b42bd27abf5e171e877b48b9.zip
Fix bug in recent styled_format change
Problem reported by Kaushal Modi in: http://lists.gnu.org/archive/html/emacs-devel/2017-10/msg00141.html * src/editfns.c (styled_format): Fix bug where USE_SAFE_ALLOCA was not always followed by SAFE_FREE. This bug was introduced in my patch 2017-09-26T23:31:57Z!eggert@cs.ucla.edu entitled "Avoid some unnecessary copying in Fformat etc."
Diffstat (limited to 'src/editfns.c')
-rw-r--r--src/editfns.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/editfns.c b/src/editfns.c
index d88a913c667..e65bd34da87 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -4179,6 +4179,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message)
multibyte character of the previous string. This flag tells if we
must consider such a situation or not. */
bool maybe_combine_byte;
+ Lisp_Object val;
bool arg_intervals = false;
USE_SAFE_ALLOCA;
sa_avail -= sizeof initial_buffer;
@@ -4417,7 +4418,10 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message)
{
if (format == end && format - format_start == 2
&& ! string_intervals (args[0]))
- return arg;
+ {
+ val = arg;
+ goto return_val;
+ }
/* handle case (precision[n] >= 0) */
@@ -4862,11 +4866,14 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message)
emacs_abort ();
if (! new_result)
- return args[0];
+ {
+ val = args[0];
+ goto return_val;
+ }
if (maybe_combine_byte)
nchars = multibyte_chars_in_text ((unsigned char *) buf, p - buf);
- Lisp_Object val = make_specified_string (buf, nchars, p - buf, multibyte);
+ val = make_specified_string (buf, nchars, p - buf, multibyte);
/* If the format string has text properties, or any of the string
arguments has text properties, set up text properties of the
@@ -4964,6 +4971,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message)
}
}
+ return_val:
/* If we allocated BUF or INFO with malloc, free it too. */
SAFE_FREE ();