emacs-devel
[Top][All Lists]
Advanced

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

Re: wrong-type-argument charsetp unbound error in emacs-unicode-2 curren


From: Bob Halley
Subject: Re: wrong-type-argument charsetp unbound error in emacs-unicode-2 current
Date: Sun, 05 Nov 2006 23:04:07 -0800
User-agent: Thunderbird 1.5.0.7 (X11/20060909)

I ran emacs under gdb, stepping through Fccl_execute_on_string. When doing the "is this a utf-8 string" test on "foo", I caught it doing a massive character copy of millions of characters. This happened because ccl.produced was a large number (around 5 million).

I then went looking for a reason for ccl.produced to be so wrong. The CCL program in question has a "buffer magnification" of zero, which means "produce no bytes". In this case the current destination pointer, dst, is set to NULL. A NULL dst causes the calculation of ccl->produced just after the ccl_finish tag in ccl_driver() to be wrong, because the code does

ccl->produced = dst - destination

I changed this code (patch attached) so that it set ccl->produced to zero if dst was NULL. With this change, both the type error and the segfault no longer happen. (The type error is fixed because we're no longer reading random memory and treating it as encoded characters.)

Regards,

/Bob

Index: src/ccl.c
===================================================================
RCS file: /sources/emacs/emacs/src/ccl.c,v
retrieving revision 1.82.4.14
diff -u -r1.82.4.14 ccl.c
--- src/ccl.c   3 Mar 2006 05:13:48 -0000       1.82.4.14
+++ src/ccl.c   6 Nov 2006 06:50:23 -0000
@@ -1782,7 +1782,10 @@
   ccl->stack_idx = stack_idx;
   ccl->prog = ccl_prog;
   ccl->consumed = src - source;
-  ccl->produced = dst - destination;
+  if (dst != NULL)
+         ccl->produced = dst - destination;
+  else
+         ccl->produced = 0;
 }
 
 /* Resolve symbols in the specified CCL code (Lisp vector).  This

reply via email to

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