all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kenichi Handa <handa@m17n.org>
To: Wang Diancheng <dianchengwang@gmail.com>
Cc: emacs-pretest-bug@gnu.org, emacs-devel@gnu.org
Subject: bug#1900: 23.0.60; detect attached file coding system, make emacs crash.
Date: Wed, 14 Jan 2009 21:53:44 +0900	[thread overview]
Message-ID: <E1LN5Fg-0000hJ-8L__39276.3700140224$1231938546$gmane$org@etlken.m17n.org> (raw)
In-Reply-To: <877i51fd95.fsf@redflag-linux.com> (message from Wang Diancheng on Mon, 12 Jan 2009 10:51:18 +0800)

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






      parent reply	other threads:[~2009-01-14 12:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-12  2:51 23.0.60; detect attached file coding system, make emacs crash Wang Diancheng
2009-01-12 13:48 ` Stefan Monnier
2009-01-14 12:53 ` Kenichi Handa
2009-01-14 13:01   ` Juanma Barranquero
2009-01-15  0:39     ` Kenichi Handa
2009-01-14 12:53 ` Kenichi Handa [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='E1LN5Fg-0000hJ-8L__39276.3700140224$1231938546$gmane$org@etlken.m17n.org' \
    --to=handa@m17n.org \
    --cc=1900@emacsbugs.donarmstrong.com \
    --cc=dianchengwang@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=emacs-pretest-bug@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.