GNU bug report logs - #1900
23.0.60; detect attached file coding system, make emacs crash.

Previous Next

Package: emacs;

Reported by: Kenichi Handa <handa <at> m17n.org>

Date: Wed, 14 Jan 2009 13:00:02 UTC

Severity: normal

Done: Chong Yidong <cyd <at> stupidchicken.com>

Bug is archived. No further changes may be made.

Full log


Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Kenichi Handa <handa <at> m17n.org>
To: Wang Diancheng <dianchengwang <at> gmail.com>
Cc: emacs-pretest-bug <at> gnu.org, emacs-devel <at> gnu.org
Subject: Re: 23.0.60; detect attached file coding system, make emacs crash.
Date: Wed, 14 Jan 2009 21:53:44 +0900
In article <877i51fd95.fsf <at> redflag-linux.com>, Wang Diancheng <dianchengwang <at> 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 <at> 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 <at> 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 <at> m17n.org




This bug report was last modified 16 years and 137 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.