summaryrefslogtreecommitdiff
path: root/src/coding.c
diff options
context:
space:
mode:
authorKenichi Handa <handa@gnu.org>2012-09-30 22:25:11 +0900
committerKenichi Handa <handa@gnu.org>2012-09-30 22:25:11 +0900
commit95402d5faa114a311cabfb8c64cf22a93787a066 (patch)
treed3a009a5d45c360a4137ec75ab47e0ac3805605a /src/coding.c
parent51c4474efc354c0e1ecc06c3014e06a3eca9682a (diff)
downloademacs-95402d5faa114a311cabfb8c64cf22a93787a066.tar.gz
coding.c (decode_coding_ccl, encode_coding_ccl): Pay attention to the buffer relocation which may be caused by ccl_driver.
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/coding.c b/src/coding.c
index 4b3d22f956c..40e67b9a6c8 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -5106,6 +5106,7 @@ decode_coding_ccl (struct coding_system *coding)
while (1)
{
const unsigned char *p = src;
+ ptrdiff_t offset;
int i = 0;
if (multibytep)
@@ -5123,8 +5124,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];
@@ -5177,8 +5187,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);