diff -u -r1.2 TermBuffer.cs
--- beagled/Lucene.Net/Index/TermBuffer.cs	6 Oct 2005 19:29:55 -0000	1.2
+++ beagled/Lucene.Net/Index/TermBuffer.cs	12 Apr 2006 03:25:47 -0000
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 using System;
+using Beagle.Util;
 using IndexInput = Lucene.Net.Store.IndexInput;
 namespace Lucene.Net.Index
 {
@@ -53,10 +54,19 @@
 		
         private void  SetTextLength(int newLength)
         {
+		if (textLength > text.Length)
+			Logger.Log.Error ("textLength (" + textLength + ") > text.Length (" + text.Length + ")");
+
             if (text.Length < newLength)
             {
                 char[] newText = new char[newLength];
-                Array.Copy(text, 0, newText, 0, textLength);
+		if (textLength > 0) {
+			if (textLength > text.Length)
+				Logger.Log.Error ("textLength (" + textLength + ") > text.Length (" + text.Length + ")");
+			if (textLength > newLength)
+				Logger.Log.Error ("textLength (" + textLength + ") > newLength (" + newLength + ") (text.Length = " + text.Length + ")");
+                	Array.Copy(text, 0, newText, 0, textLength);
+		}
                 text = newText;
             }
             textLength = newLength;
@@ -82,8 +92,9 @@
             }
 			
             // copy text into the buffer
-            SetTextLength(term.Text().Length);
-			text = term.Text().ToCharArray();
+		char[] chars = term.Text().ToCharArray();
+		SetTextLength(chars.Length);
+               	Array.Copy(chars, 0, text, 0, textLength);
 
             this.field = term.Field();
             this.term = term;
