summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenichi Handa <handa@gnu.org>2012-09-30 23:44:30 +0900
committerKenichi Handa <handa@gnu.org>2012-09-30 23:44:30 +0900
commit163227893c97b5b41039ea9d5ceadb7e5b2d570c (patch)
treedc129a60013f285c27859ae57cc0686f5a1adc5b
parentd7e642cc001a237dda8511f99b284e1a22865024 (diff)
parentc194970e15b6d6efa07697679a25dfab3aa76442 (diff)
downloademacs-163227893c97b5b41039ea9d5ceadb7e5b2d570c.tar.gz
emacs-163227893c97b5b41039ea9d5ceadb7e5b2d570c.tar.bz2
emacs-163227893c97b5b41039ea9d5ceadb7e5b2d570c.zip
coding.c (decode_coding_ccl, encode_coding_ccl): Pay attention to the buffer relocation which may be caused by ccl_driver.
-rw-r--r--src/ChangeLog5
-rw-r--r--src/coding.c17
2 files changed, 22 insertions, 0 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 119651e0651..1f5ad1e6d05 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2012-09-30 Kenichi Handa <handa@gnu.org>
+
+ * coding.c (decode_coding_ccl, encode_coding_ccl): Pay attention
+ to the buffer relocation which may be caused by ccl_driver.
+
2012-09-30 Jan Djärv <jan.h.d@swipnet.se>
* xfns.c (Fx_file_dialog): Update comment.
diff --git a/src/coding.c b/src/coding.c
index 13f53ad5abc..32d300b9923 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -5059,6 +5059,7 @@ decode_coding_ccl (struct coding_system *coding)
while (1)
{
const unsigned char *p = src;
+ ptrdiff_t offset;
int i = 0;
if (multibytep)
@@ -5076,8 +5077,17 @@ decode_coding_ccl (struct coding_system *coding)
if (p == src_end && coding->mode & CODING_MODE_LAST_BLOCK)
ccl->last_block = 1;
+ /* As ccl_driver calls DECODE_CHAR, buffer may be relocated. */
+ charset_map_loaded = 0;
ccl_driver (ccl, source_charbuf, charbuf, i, charbuf_end - charbuf,
charset_list);
+ if (charset_map_loaded
+ && (offset = coding_change_source (coding)))
+ {
+ p += offset;
+ src += offset;
+ src_end += offset;
+ }
charbuf += ccl->produced;
if (multibytep)
src += source_byteidx[ccl->consumed];
@@ -5130,8 +5140,15 @@ encode_coding_ccl (struct coding_system *coding)
do
{
+ ptrdiff_t offset;
+
+ /* As ccl_driver calls DECODE_CHAR, buffer may be relocated. */
+ charset_map_loaded = 0;
ccl_driver (ccl, charbuf, destination_charbuf,
charbuf_end - charbuf, 1024, charset_list);
+ if (charset_map_loaded
+ && (offset = coding_change_destination (coding)))
+ dst += offset;
if (multibytep)
{
ASSURE_DESTINATION (ccl->produced * 2);