[Mono-bugs] [Bug 77274][Nor] Changed - bug in CP950 encoding - GetChars raises IndexOutOfRangeException unexpectedly

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Mon Jan 16 12:07:14 EST 2006


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by atsushi at ximian.com.

http://bugzilla.ximian.com/show_bug.cgi?id=77274

--- shadow/77274	2006-01-16 08:37:32.000000000 -0500
+++ shadow/77274.tmp.11838	2006-01-16 12:07:13.000000000 -0500
@@ -5,19 +5,19 @@
 OS Details: 
 Status: NEW   
 Resolution: 
 Severity: Unknown
 Priority: Normal
 Component: CORLIB
-AssignedTo: mono-bugs at ximian.com                            
+AssignedTo: atsushi at ximian.com                            
 ReportedBy: bruno at clisp.org               
 QAContact: mono-bugs at ximian.com
 TargetMilestone: ---
 URL: 
 Cc: 
-Summary: bug in CP950 encoding - GetChars method
+Summary: bug in CP950 encoding - GetChars raises IndexOutOfRangeException unexpectedly
 
 Please fill in this template when reporting a bug, unless you know what you are doing. 
 Description of Problem: 
  
 The CP950 encoding converter throws exceptions where it shouldn't. 
  
@@ -54,6 +54,57 @@
 Source code see attachment.
 
 ------- Additional Comments From bruno at clisp.org  2006-01-16 08:37 -------
 Created an attachment (id=16354)
 monobug.cs
 
+
+------- Additional Comments From atsushi at ximian.com  2006-01-16 12:07 -------
+Good repro code to find out where the exception orrus:
+
+using System; /* String, Console */
+using System.Text; /* Encoding */
+
+public class monobug {
+  public static int Main (String[] args) {
+    try {
+      Encoding encoding = Encoding.GetEncoding(950);
+      for (int i0 = 0; i0 < 0x100; i0++) {
+        for (int i1 = 0; i1 < 0x100; i1++) {
+          Console.WriteLine ("{0:X02} {1:X02}", i0, i1);
+          encoding.GetChars(new byte[] { (byte)i0, (byte)i1 });
+        }
+      }
+    } catch (Exception e) {
+      Console.Error.WriteLine(e);
+      Console.Error.WriteLine(e.StackTrace);
+      return 1;
+    }
+    return 0;
+  }
+}
+
+Actual result:
+
+...
+(snip)
+...
+A0 FF
+A1 00
+System.IndexOutOfRangeException: Array index is out of range.
+in <0x00124> I18N.CJK.CP950:GetChars (System.Byte[] bytes, Int32
+byteIndex, Int32 byteCount, System.Char[] chars, Int32 charIndex)
+in <0x00072> I18N.CJK.DbcsEncoding:GetCharCount (System.Byte[] bytes,
+Int32 index, Int32 count)
+in <0x00027> System.Text.Encoding:GetChars (System.Byte[] bytes)
+in <0x000d7> monobug:Main (System.String[] args)
+in <0x00124> I18N.CJK.CP950:GetChars (System.Byte[] bytes, Int32
+byteIndex, Int32 byteCount, System.Char[] chars, Int32 charIndex)
+in <0x00072> I18N.CJK.DbcsEncoding:GetCharCount (System.Byte[] bytes,
+Int32 index, Int32 count)
+in <0x00027> System.Text.Encoding:GetChars (System.Byte[] bytes)
+in <0x000d7> monobug:Main (System.String[] args)
+
+Expected result:
+
+no error.
+


More information about the mono-bugs mailing list