[1280] in Coldmud discussion meeting

root meeting help first previous next next in chain last in chain last

[COLD] [patch] bufidx

daemon@ATHENA.MIT.EDU (Mon Apr 21 09:18:56 1997 )

Date: Mon, 21 Apr 1997 15:08:55 +0200 (MET DST)
From: Miroslav Silovic <silovic@mare.zesoi.fer.hr>
To: coldstuff@cold.org


This (hopefully) fixes the crash. :)

--- orig/Genesis-1.0p27/src/data/buffer.c	Mon Feb 10 05:28:20 1997
+++ Genesis-1.0p27/src/data/buffer.c	Mon Apr 21 15:08:01 1997
@@ -384,7 +384,8 @@
 int buffer_index(cBuf * buf, uChar * ss, int slen, int origin) {
     int     len;
     uChar * s,
-          * p;
+          * p,
+	  * lastp;
     Bool    reverse = NO;
 
     s = buf->s;
@@ -417,10 +418,12 @@
             return p ? ((p - s) + 1) : 0;
         } else {
             slen--;
+	    lastp = s - 1;
             while (p) {
                 if (MEMCMP(p + 1, ss + 1, slen) == 0)
                     return (p - s) + 1;
-                len -= (p - s)+1;
+                len -= p - lastp;
+                lastp = p;
                 p = (uChar *) memchr(p+1, *ss, len);
             }
         }