tsam: fix off-by-one in buffer merge. exposed by UTFmax==4 - plan9port - [fork] Plan 9 from user space
git clone git://src.adamsgaard.dk/plan9port
Log
Files
Refs
README
LICENSE
---
commit 846cec9ebc33dcbdd93d425a92fab6bc7acf355c
parent 1d919bc08079e8f6221b3e83150374fe876989c8
Author: Russ Cox 
Date:   Sun,  6 Dec 2009 17:27:08 -0800

sam: fix off-by-one in buffer merge.
  exposed by UTFmax==4

R=rsc
http://codereview.appspot.com/165071

Diffstat:
  M src/cmd/sam/file.c                  |       4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/src/cmd/sam/file.c b/src/cmd/sam/file.c
t@@ -139,7 +139,7 @@ loginsert(File *f, uint p0, Rune *s, uint ns)
 
         if(merge.f != f
         || p0-(merge.p0+merge.n)>Maxmerge                        /* too far */
-        || merge.nbuf+((p0+ns)-(merge.p0+merge.n))>RBUFSIZE)        /* too long */
+        || merge.nbuf+((p0+ns)-(merge.p0+merge.n))>=RBUFSIZE)        /* too long */
                 flushmerge();
 
         if(ns>=RBUFSIZE){
t@@ -178,7 +178,7 @@ logdelete(File *f, uint p0, uint p1)
 
         if(merge.f != f
         || p0-(merge.p0+merge.n)>Maxmerge                        /* too far */
-        || merge.nbuf+(p0-(merge.p0+merge.n))>RBUFSIZE){        /* too long */
+        || merge.nbuf+(p0-(merge.p0+merge.n))>=RBUFSIZE){        /* too long */
                 flushmerge();
                 merge.f = f;
                 merge.p0 = p0;