aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
authorEli Zaretskii2019-03-27 20:34:22 +0200
committerEli Zaretskii2019-03-27 20:34:22 +0200
commita35a1f6a9406bc98b4ab83489e5dc7843ffacfb6 (patch)
treec6167df9e04a63952c0ef7bf1d4b0a292887c5d4 /src/coding.c
parenta697d1e638eabdb3eb32337fde6d802ef712eaf8 (diff)
downloademacs-a35a1f6a9406bc98b4ab83489e5dc7843ffacfb6.tar.gz
emacs-a35a1f6a9406bc98b4ab83489e5dc7843ffacfb6.zip
Attempt to fix crashes under GDB on Windows 10
* src/pdumper.c (dump_discard_mem) [VM_SUPPORTED == VM_MS_WINDOWS]: Don't pass NULL pointer as last argument to VirtualProtect. Reported by Martin Rudalics <rudalics@gmx.at>.
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c87
1 files changed, 49 insertions, 38 deletions
diff --git a/src/coding.c b/src/coding.c
index 905c7ced849..c6d96436770 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -7798,42 +7798,6 @@ static Lisp_Object Vcode_conversion_reused_workbuf;
7798static bool reused_workbuf_in_use; 7798static bool reused_workbuf_in_use;
7799 7799
7800 7800
7801/* Return a working buffer of code conversion. MULTIBYTE specifies the
7802 multibyteness of returning buffer. */
7803
7804static Lisp_Object
7805make_conversion_work_buffer (bool multibyte)
7806{
7807 Lisp_Object name, workbuf;
7808 struct buffer *current;
7809
7810 if (reused_workbuf_in_use)
7811 {
7812 name = Fgenerate_new_buffer_name (Vcode_conversion_workbuf_name, Qnil);
7813 workbuf = Fget_buffer_create (name);
7814 }
7815 else
7816 {
7817 reused_workbuf_in_use = 1;
7818 if (NILP (Fbuffer_live_p (Vcode_conversion_reused_workbuf)))
7819 Vcode_conversion_reused_workbuf
7820 = Fget_buffer_create (Vcode_conversion_workbuf_name);
7821 workbuf = Vcode_conversion_reused_workbuf;
7822 }
7823 current = current_buffer;
7824 set_buffer_internal (XBUFFER (workbuf));
7825 /* We can't allow modification hooks to run in the work buffer. For
7826 instance, directory_files_internal assumes that file decoding
7827 doesn't compile new regexps. */
7828 Fset (Fmake_local_variable (Qinhibit_modification_hooks), Qt);
7829 Ferase_buffer ();
7830 bset_undo_list (current_buffer, Qt);
7831 bset_enable_multibyte_characters (current_buffer, multibyte ? Qt : Qnil);
7832 set_buffer_internal (current);
7833 return workbuf;
7834}
7835
7836
7837static void 7801static void
7838code_conversion_restore (Lisp_Object arg) 7802code_conversion_restore (Lisp_Object arg)
7839{ 7803{
@@ -7846,7 +7810,12 @@ code_conversion_restore (Lisp_Object arg)
7846 if (EQ (workbuf, Vcode_conversion_reused_workbuf)) 7810 if (EQ (workbuf, Vcode_conversion_reused_workbuf))
7847 reused_workbuf_in_use = 0; 7811 reused_workbuf_in_use = 0;
7848 else 7812 else
7849 Fkill_buffer (workbuf); 7813 {
7814 ptrdiff_t count = SPECPDL_INDEX ();
7815 specbind (Qbuffer_list_update_hook, Qnil);
7816 Fkill_buffer (workbuf);
7817 unbind_to (count, Qnil);
7818 }
7850 } 7819 }
7851 set_buffer_internal (XBUFFER (current)); 7820 set_buffer_internal (XBUFFER (current));
7852} 7821}
@@ -7857,9 +7826,51 @@ code_conversion_save (bool with_work_buf, bool multibyte)
7857 Lisp_Object workbuf = Qnil; 7826 Lisp_Object workbuf = Qnil;
7858 7827
7859 if (with_work_buf) 7828 if (with_work_buf)
7860 workbuf = make_conversion_work_buffer (multibyte); 7829 {
7830 ptrdiff_t count = SPECPDL_INDEX ();
7831 if (reused_workbuf_in_use)
7832 {
7833 Lisp_Object name
7834 = Fgenerate_new_buffer_name (Vcode_conversion_workbuf_name, Qnil);
7835 specbind (Qbuffer_list_update_hook, Qnil);
7836 workbuf = Fget_buffer_create (name);
7837 unbind_to (count, Qnil);
7838 }
7839 else
7840 {
7841 if (NILP (Fbuffer_live_p (Vcode_conversion_reused_workbuf)))
7842 {
7843 specbind (Qbuffer_list_update_hook, Qnil);
7844 Vcode_conversion_reused_workbuf
7845 = Fget_buffer_create (Vcode_conversion_workbuf_name);
7846 unbind_to (count, Qnil);
7847 }
7848 workbuf = Vcode_conversion_reused_workbuf;
7849 }
7850 }
7861 record_unwind_protect (code_conversion_restore, 7851 record_unwind_protect (code_conversion_restore,
7862 Fcons (Fcurrent_buffer (), workbuf)); 7852 Fcons (Fcurrent_buffer (), workbuf));
7853 if (!NILP (workbuf))
7854 {
7855 struct buffer *current = current_buffer;
7856 set_buffer_internal (XBUFFER (workbuf));
7857 /* We can't allow modification hooks to run in the work buffer. For
7858 instance, directory_files_internal assumes that file decoding
7859 doesn't compile new regexps. */
7860 Fset (Fmake_local_variable (Qinhibit_modification_hooks), Qt);
7861 Ferase_buffer ();
7862 bset_undo_list (current_buffer, Qt);
7863 bset_enable_multibyte_characters (current_buffer, multibyte ? Qt : Qnil);
7864 if (EQ (workbuf, Vcode_conversion_reused_workbuf))
7865 reused_workbuf_in_use = 1;
7866 else
7867 {
7868 Fset (Fmake_local_variable (Qkill_buffer_query_functions), Qnil);
7869 Fset (Fmake_local_variable (Qkill_buffer_hook), Qnil);
7870 }
7871 set_buffer_internal (current);
7872 }
7873
7863 return workbuf; 7874 return workbuf;
7864} 7875}
7865 7876