diff src/text.c @ 841:44478bd99873

[xemacs-hg @ 2002-05-14 15:15:58 by ben] crash fixes text.c: Fix bug leading to crashes with multibyte text. win32.c: Fix crash due to errant xfree(). xemacs.mak: Run tests with the packages so we don't get errors about advice not present, etc.
author ben
date Tue, 14 May 2002 15:16:08 +0000
parents 6728e641994e
children e7ee5f8bde58
line wrap: on
line diff
--- a/src/text.c	Tue May 14 13:04:00 2002 +0000
+++ b/src/text.c	Tue May 14 15:16:08 2002 +0000
@@ -1189,7 +1189,16 @@
 	  {
 	    dst += the_dst_used;
 	    dstlen -= the_dst_used;
-	    if (!dstlen)
+	    /* Stop if we didn't use all of the source text.  Also stop
+	       if the destination is full.  We need the first test because
+	       there might be a couple bytes left in the destination, but
+	       not enough to fit a full character.  The first test will in
+	       fact catch the vast majority of cases where the destination
+	       is empty, too -- but in case the destination holds *exactly*
+	       the run length, we put in the second check. (It shouldn't
+	       really matter though -- next time through we'll just get a
+	       0.) */
+	    if (the_src_used < runlen || !dstlen)
 	      break;
 	  }
       }