emacs-devel
[Top][All Lists]
Advanced

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

Re: 23.0.60; detect attached file coding system, make emacs crash.


From: Kenichi Handa
Subject: Re: 23.0.60; detect attached file coding system, make emacs crash.
Date: Wed, 14 Jan 2009 21:53:44 +0900

In article <address@hidden>, Wang Diancheng <address@hidden> writes:

> detect attached file coding system with following code, make emacs crash

> (with-temp-buffer
>     (insert-file-contents "/home/dcwang/1.txt")
>     (detect-coding-region (point-min) (point-max) t))

Thank you for the bug report.  I've just committed a fix.
But, the above code doesn't work as you expect because
insert-file-contents inserts already decoded text in a
buffer.  You should do something like this, and this is
faster.

(with-temp-buffer
  (let ((coding-system-for-read 'no-conversion))
    (insert-file-contents "/home/dcwang/1.txt")
    (detect-coding-region (point-min) (point-max) t)))

Chong Yidong <address@hidden> writes:

> Looks like detect_coding_utf_16 forgets to check for negative values of
> ONE_MORE_BYTE.

Yes.  But...

> Handa-san, could you check the following patch?

>         ONE_MORE_BYTE (c1);
>         ONE_MORE_BYTE (c2);
> + 
> +       if (c1 < 0 || c2 < 0)
> +         break;
> + 
>         if (! e[c1])
>           {
>             e[c1] = 1;

That's not enough. c1 and c2 must be checked here too:

      e[c1] = 1;
      o[c2] = 1;

"Juanma Barranquero" <address@hidden> writes:

> Don't you need a test also before lines 1605-1606, where c1 and c2 are
> used as array indexes?

That's not necessary because if c1 and c2 are non-negative,
it is assured that they are byte values; i.e. less than 256.

---
Kenichi Handa
address@hidden




reply via email to

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