emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/emacs-24 r108020: Avoid buffer text relocat


From: Eli Zaretskii
Subject: [Emacs-diffs] /srv/bzr/emacs/emacs-24 r108020: Avoid buffer text relocations in calls to STRING_CHAR_* macros.
Date: Mon, 28 May 2012 19:50:10 +0300
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 108020
fixes bug: http://debbugs.gnu.org/11519
committer: Eli Zaretskii <address@hidden>
branch nick: emacs-24
timestamp: Mon 2012-05-28 19:50:10 +0300
message:
  Avoid buffer text relocations in calls to STRING_CHAR_* macros.
  
   src/charset.c (maybe_unify_char): Inhibit relocation of buffer text
   for the duration of call to load_charset, to avoid problems with
   callers of maybe_unify_char that access buffer text through C
   pointers.
   src/ralloc.c (r_alloc_inhibit_buffer_relocation): Increment and
   decrement the inhibition flag, instead of just setting or
   resetting it.
modified:
  src/ChangeLog
  src/charset.c
  src/ralloc.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2012-05-24 11:21:34 +0000
+++ b/src/ChangeLog     2012-05-28 16:50:10 +0000
@@ -1,3 +1,14 @@
+2012-05-23  Eli Zaretskii  <address@hidden>
+
+       * charset.c (maybe_unify_char): Inhibit relocation of buffer text
+       for the duration of call to load_charset, to avoid problems with
+       callers of maybe_unify_char that access buffer text through C
+       pointers.
+
+       * ralloc.c (r_alloc_inhibit_buffer_relocation): Increment and
+       decrement the inhibition flag, instead of just setting or
+       resetting it.
+
 2012-05-24  Ken Brown  <address@hidden>
 
        * callproc.c (Fcall_process): Restore a line that was accidentally

=== modified file 'src/charset.c'
--- a/src/charset.c     2012-01-19 07:21:25 +0000
+++ b/src/charset.c     2012-05-28 16:50:10 +0000
@@ -1641,6 +1641,12 @@
     return c;
 
   CHECK_CHARSET_GET_CHARSET (val, charset);
+#ifdef REL_ALLOC
+  /* The call to load_charset below can allocate memory, whcih screws
+     callers of this function through STRING_CHAR_* macros that hold C
+     pointers to buffer text, if REL_ALLOC is used.  */
+  r_alloc_inhibit_buffer_relocation (1);
+#endif
   load_charset (charset, 1);
   if (! inhibit_load_charset_map)
     {
@@ -1656,6 +1662,9 @@
       if (unified > 0)
        c = unified;
     }
+#ifdef REL_ALLOC
+  r_alloc_inhibit_buffer_relocation (0);
+#endif
   return c;
 }
 

=== modified file 'src/ralloc.c'
--- a/src/ralloc.c      2012-05-23 17:32:28 +0000
+++ b/src/ralloc.c      2012-05-28 16:50:10 +0000
@@ -1204,7 +1204,12 @@
 void
 r_alloc_inhibit_buffer_relocation (int inhibit)
 {
-  use_relocatable_buffers = !inhibit;
+  if (use_relocatable_buffers < 0)
+    use_relocatable_buffers = 0;
+  if (inhibit)
+    use_relocatable_buffers++;
+  else if (use_relocatable_buffers > 0)
+    use_relocatable_buffers--;
 }
 
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]