aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2017-10-06 10:32:46 -0700
committerPaul Eggert2017-10-06 10:33:53 -0700
commit9226cf325421a168b42bd27abf5e171e877b48b9 (patch)
tree4d36ec218d3f674f159bc9c7a7418975d4b1062c /src
parentfa92f0c44715fc49e19de001ee8b217ce847d954 (diff)
downloademacs-9226cf325421a168b42bd27abf5e171e877b48b9.tar.gz
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')
-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)
4179 multibyte character of the previous string. This flag tells if we 4179 multibyte character of the previous string. This flag tells if we
4180 must consider such a situation or not. */ 4180 must consider such a situation or not. */
4181 bool maybe_combine_byte; 4181 bool maybe_combine_byte;
4182 Lisp_Object val;
4182 bool arg_intervals = false; 4183 bool arg_intervals = false;
4183 USE_SAFE_ALLOCA; 4184 USE_SAFE_ALLOCA;
4184 sa_avail -= sizeof initial_buffer; 4185 sa_avail -= sizeof initial_buffer;
@@ -4417,7 +4418,10 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message)
4417 { 4418 {
4418 if (format == end && format - format_start == 2 4419 if (format == end && format - format_start == 2
4419 && ! string_intervals (args[0])) 4420 && ! string_intervals (args[0]))
4420 return arg; 4421 {
4422 val = arg;
4423 goto return_val;
4424 }
4421 4425
4422 /* handle case (precision[n] >= 0) */ 4426 /* handle case (precision[n] >= 0) */
4423 4427
@@ -4862,11 +4866,14 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message)
4862 emacs_abort (); 4866 emacs_abort ();
4863 4867
4864 if (! new_result) 4868 if (! new_result)
4865 return args[0]; 4869 {
4870 val = args[0];
4871 goto return_val;
4872 }
4866 4873
4867 if (maybe_combine_byte) 4874 if (maybe_combine_byte)
4868 nchars = multibyte_chars_in_text ((unsigned char *) buf, p - buf); 4875 nchars = multibyte_chars_in_text ((unsigned char *) buf, p - buf);
4869 Lisp_Object val = make_specified_string (buf, nchars, p - buf, multibyte); 4876 val = make_specified_string (buf, nchars, p - buf, multibyte);
4870 4877
4871 /* If the format string has text properties, or any of the string 4878 /* If the format string has text properties, or any of the string
4872 arguments has text properties, set up text properties of the 4879 arguments has text properties, set up text properties of the
@@ -4964,6 +4971,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message)
4964 } 4971 }
4965 } 4972 }
4966 4973
4974 return_val:
4967 /* If we allocated BUF or INFO with malloc, free it too. */ 4975 /* If we allocated BUF or INFO with malloc, free it too. */
4968 SAFE_FREE (); 4976 SAFE_FREE ();
4969 4977