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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 1900 in the body.
You can then email your comments to 1900 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1900; Package emacs. (Wed, 14 Jan 2009 13:00:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Kenichi Handa <handa <at> m17n.org>:
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Wed, 14 Jan 2009 13:00:02 GMT) Full text and rfc822 format available.

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




bug closed, send any further explanations to Kenichi Handa <handa <at> m17n.org> Request was from Chong Yidong <cyd <at> stupidchicken.com> to control <at> emacsbugs.donarmstrong.com. (Wed, 14 Jan 2009 13:40:05 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> emacsbugs.donarmstrong.com. (Wed, 11 Feb 2009 15:24:08 GMT) Full text and rfc822 format available.

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.