Subject: bug#1864: 23.0.60; detect attached file coding system, make emacs crash.

From: Chong Yidong <[email-masked]>
Date: Tue, 13 Jan 2009 22:54:29 -0500

> 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))

Looks like detect_coding_utf_16 forgets to check for negative values of
ONE_MORE_BYTE.  Handa-san, could you check the following patch?

*** trunk/src/coding.c.~1.406.~	2009-01-11 08:23:34.000000000 -0500
--- trunk/src/coding.c	2009-01-13 22:54:10.000000000 -0500
***************
*** 1612,1617 ****
--- 1612,1621 ----
  	{
  	  ONE_MORE_BYTE (c1);
  	  ONE_MORE_BYTE (c2);
+ 
+ 	  if (c1 < 0 || c2 < 0)
+ 	    break;
+ 
  	  if (! e[c1])
  	    {
  	      e[c1] = 1;