From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kenichi Handa Newsgroups: gmane.emacs.devel,gmane.emacs.pretest.bugs Subject: Re: 23.0.60; detect attached file coding system, make emacs crash. Date: Wed, 14 Jan 2009 21:53:44 +0900 Message-ID: References: <877i51fd95.fsf@redflag-linux.com> NNTP-Posting-Host: lo.gmane.org X-Trace: ger.gmane.org 1231937672 7140 80.91.229.12 (14 Jan 2009 12:54:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 14 Jan 2009 12:54:32 +0000 (UTC) Cc: emacs-pretest-bug@gnu.org, emacs-devel@gnu.org To: Wang Diancheng Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jan 14 13:55:42 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LN5HL-00077N-RI for ged-emacs-devel@m.gmane.org; Wed, 14 Jan 2009 13:55:28 +0100 Original-Received: from localhost ([127.0.0.1]:46380 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LN5G5-0002yV-Bv for ged-emacs-devel@m.gmane.org; Wed, 14 Jan 2009 07:54:09 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LN5Fz-0002uP-Ug for emacs-devel@gnu.org; Wed, 14 Jan 2009 07:54:04 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LN5Fw-0002tD-P2 for emacs-devel@gnu.org; Wed, 14 Jan 2009 07:54:02 -0500 Original-Received: from [199.232.76.173] (port=37637 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LN5Fu-0002su-VO for emacs-devel@gnu.org; Wed, 14 Jan 2009 07:53:59 -0500 Original-Received: from mx1.aist.go.jp ([150.29.246.133]:52716) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LN5Fp-000335-Mf; Wed, 14 Jan 2009 07:53:54 -0500 Original-Received: from rqsmtp2.aist.go.jp (rqsmtp2.aist.go.jp [150.29.254.123]) by mx1.aist.go.jp with ESMTP id n0ECriYt026634; Wed, 14 Jan 2009 21:53:44 +0900 (JST) env-from (handa@m17n.org) Original-Received: from smtp4.aist.go.jp by rqsmtp2.aist.go.jp with ESMTP id n0ECrixn003580; Wed, 14 Jan 2009 21:53:44 +0900 (JST) env-from (handa@m17n.org) Original-Received: by smtp4.aist.go.jp with ESMTP id n0ECri5E011922; Wed, 14 Jan 2009 21:53:44 +0900 (JST) env-from (handa@m17n.org) Original-Received: from handa by etlken.m17n.org with local (Exim 4.69) (envelope-from ) id 1LN5Fg-0000hJ-8L; Wed, 14 Jan 2009 21:53:44 +0900 In-reply-to: <877i51fd95.fsf@redflag-linux.com> (message from Wang Diancheng on Mon, 12 Jan 2009 10:51:18 +0800) X-detected-operating-system: by monty-python.gnu.org: Solaris 9 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:107846 gmane.emacs.pretest.bugs:23691 Archived-At: In article <877i51fd95.fsf@redflag-linux.com>, Wang Diancheng 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 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" 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