aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2012-05-28 19:50:10 +0300
committerEli Zaretskii2012-05-28 19:50:10 +0300
commit291d430f5f184c8a9438eace09b141131de343e8 (patch)
tree6310a9eb6bbf4643505fa67d0b012dad81624aa0 /src
parente383e32d7a00bf286db1dc6b05b6219f0eaab8dc (diff)
downloademacs-291d430f5f184c8a9438eace09b141131de343e8.tar.gz
emacs-291d430f5f184c8a9438eace09b141131de343e8.zip
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. Fixes: debbugs:11519
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog11
-rw-r--r--src/charset.c9
-rw-r--r--src/ralloc.c7
3 files changed, 26 insertions, 1 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 0b1ef220fc0..ec5725af2bc 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,14 @@
12012-05-23 Eli Zaretskii <eliz@gnu.org>
2
3 * charset.c (maybe_unify_char): Inhibit relocation of buffer text
4 for the duration of call to load_charset, to avoid problems with
5 callers of maybe_unify_char that access buffer text through C
6 pointers.
7
8 * ralloc.c (r_alloc_inhibit_buffer_relocation): Increment and
9 decrement the inhibition flag, instead of just setting or
10 resetting it.
11
12012-05-24 Ken Brown <kbrown@cornell.edu> 122012-05-24 Ken Brown <kbrown@cornell.edu>
2 13
3 * callproc.c (Fcall_process): Restore a line that was accidentally 14 * callproc.c (Fcall_process): Restore a line that was accidentally
diff --git a/src/charset.c b/src/charset.c
index 57e1603fc19..d287fc0bece 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -1641,6 +1641,12 @@ maybe_unify_char (int c, Lisp_Object val)
1641 return c; 1641 return c;
1642 1642
1643 CHECK_CHARSET_GET_CHARSET (val, charset); 1643 CHECK_CHARSET_GET_CHARSET (val, charset);
1644#ifdef REL_ALLOC
1645 /* The call to load_charset below can allocate memory, whcih screws
1646 callers of this function through STRING_CHAR_* macros that hold C
1647 pointers to buffer text, if REL_ALLOC is used. */
1648 r_alloc_inhibit_buffer_relocation (1);
1649#endif
1644 load_charset (charset, 1); 1650 load_charset (charset, 1);
1645 if (! inhibit_load_charset_map) 1651 if (! inhibit_load_charset_map)
1646 { 1652 {
@@ -1656,6 +1662,9 @@ maybe_unify_char (int c, Lisp_Object val)
1656 if (unified > 0) 1662 if (unified > 0)
1657 c = unified; 1663 c = unified;
1658 } 1664 }
1665#ifdef REL_ALLOC
1666 r_alloc_inhibit_buffer_relocation (0);
1667#endif
1659 return c; 1668 return c;
1660} 1669}
1661 1670
diff --git a/src/ralloc.c b/src/ralloc.c
index db3638a54e6..2e4823dc6c1 100644
--- a/src/ralloc.c
+++ b/src/ralloc.c
@@ -1204,7 +1204,12 @@ r_alloc_reset_variable (POINTER *old, POINTER *new)
1204void 1204void
1205r_alloc_inhibit_buffer_relocation (int inhibit) 1205r_alloc_inhibit_buffer_relocation (int inhibit)
1206{ 1206{
1207 use_relocatable_buffers = !inhibit; 1207 if (use_relocatable_buffers < 0)
1208 use_relocatable_buffers = 0;
1209 if (inhibit)
1210 use_relocatable_buffers++;
1211 else if (use_relocatable_buffers > 0)
1212 use_relocatable_buffers--;
1208} 1213}
1209 1214
1210 1215