[sword-cvs] sword/src/utilfuns swbuf.cpp,1.16,1.17

sword@www.crosswire.org sword@www.crosswire.org
Thu, 15 Apr 2004 04:17:55 -0700


Update of /cvs/core/sword/src/utilfuns
In directory www:/tmp/cvs-serv18046/src/utilfuns

Modified Files:
	swbuf.cpp 
Log Message:
fixed a SWBuf bug (joachim)

Index: swbuf.cpp
===================================================================
RCS file: /cvs/core/sword/src/utilfuns/swbuf.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- swbuf.cpp	2 Apr 2004 23:54:44 -0000	1.16
+++ swbuf.cpp	15 Apr 2004 11:17:52 -0000	1.17
@@ -139,8 +139,9 @@
 /******************************************************************************
 * SWBuf::append - appends a value to the current value of this SWBuf
 */
-void SWBuf::append(const char *str, long max) {
-	unsigned long len = (max > -1) ? max : strlen(str);
+void SWBuf::append(const char *str, const long max) {
+	//make sure we only copy strlen(str) bytes if max is larger than strlen(str) is
+	unsigned long len = (max > -1) ? ((max <= strlen(str)) ? max : strlen(str)) : strlen(str);
 	assureMore(++len);
 	memcpy(end, str, len-1);
 	end += (len-1);