[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r99601: Fix bug in decoding emacs-mul
From: |
Eli Zaretskii |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r99601: Fix bug in decoding emacs-mule encoding. |
Date: |
Tue, 02 Mar 2010 22:35:44 +0200 |
User-agent: |
Bazaar (2.0.3) |
------------------------------------------------------------
revno: 99601
committer: Eli Zaretskii <address@hidden>
branch nick: trunk
timestamp: Tue 2010-03-02 22:35:44 +0200
message:
Fix bug in decoding emacs-mule encoding.
coding.c (decode_coding_emacs_mule): Fixup pointers to buffer
text that could be relocated inside the call to emacs_mule_char.
(emacs_mule_char): Use CODING_DECODE_CHAR instead of DECODE_CHAR.
(CODING_DECODE_CHAR): Add a comment describing its purpose.
modified:
src/ChangeLog
src/coding.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog 2010-03-02 04:44:28 +0000
+++ b/src/ChangeLog 2010-03-02 20:35:44 +0000
@@ -1,3 +1,10 @@
+2010-03-02 Eli Zaretskii <address@hidden>
+
+ * coding.c (decode_coding_emacs_mule): Fixup pointers to buffer
+ text that could be relocated inside the call to emacs_mule_char.
+ (emacs_mule_char): Use CODING_DECODE_CHAR instead of DECODE_CHAR.
+ (CODING_DECODE_CHAR): Add a comment describing its purpose.
+
2010-03-02 Kenichi Handa <address@hidden>
* character.c (parse_str_as_multibyte): Fix handling of the
=== modified file 'src/coding.c'
--- a/src/coding.c 2010-02-18 02:27:25 +0000
+++ b/src/coding.c 2010-03-02 20:35:44 +0000
@@ -1005,6 +1005,10 @@
}
}
+/* This wrapper macro is used to preserve validity of pointers into
+ buffer text across calls to decode_char, which could cause
+ relocation of buffers if it loads a charset map, because loading a
+ charset map allocates large structures. */
#define CODING_DECODE_CHAR(coding, src, src_base, src_end, charset, code, c) \
do { \
charset_map_loaded = 0; \
@@ -2178,7 +2182,7 @@
default:
abort ();
}
- c = DECODE_CHAR (charset, code);
+ CODING_DECODE_CHAR (coding, src, src_base, src_end, charset, code, c);
if (c < 0)
goto invalid_code;
}
@@ -2525,9 +2529,23 @@
else
{
int nchars, nbytes;
+ /* emacs_mule_char can load a charset map from a file, which
+ allocates a large structure and might cause buffer text
+ to be relocated as result. Thus, we need to remember the
+ original pointer to buffer text, and fixup all related
+ pointers after the call. */
+ const unsigned char *orig = coding->source;
+ EMACS_INT offset;
c = emacs_mule_char (coding, src_base, &nbytes, &nchars, &id,
cmp_status);
+ offset = coding->source - orig;
+ if (offset)
+ {
+ src += offset;
+ src_base += offset;
+ src_end += offset;
+ }
if (c < 0)
{
if (c == -1)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r99601: Fix bug in decoding emacs-mule encoding.,
Eli Zaretskii <=