[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#1900: 23.0.60; detect attached file coding system, make emacs crash.
From: |
Kenichi Handa |
Subject: |
bug#1900: 23.0.60; detect attached file coding system, make emacs crash. |
Date: |
Wed, 14 Jan 2009 21:53:44 +0900 |
In article <877i51fd95.fsf@redflag-linux.com>, Wang Diancheng
<dianchengwang@gmail.com> 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 <cyd@stupidchicken.com> 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" <lekktu@gmail.com> 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
handa@m17n.org