[sword-cvs] sword/src/utilfuns swbuf.cpp,1.18,1.19
sword at www.crosswire.org
sword at www.crosswire.org
Thu Jun 10 09:02:17 MST 2004
Committed by: mgruner
Update of /cvs/core/sword/src/utilfuns
In directory www:/tmp/cvs-serv17313/src/utilfuns
Modified Files:
swbuf.cpp
Log Message:
mgruner: bugfix. swbuf crashed when trying to append "\0".
C is evil. We need to be more careful with pointer stuff!
Index: swbuf.cpp
===================================================================
RCS file: /cvs/core/sword/src/utilfuns/swbuf.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- swbuf.cpp 15 Apr 2004 14:39:12 -0000 1.18
+++ swbuf.cpp 10 Jun 2004 16:02:14 -0000 1.19
@@ -140,6 +140,8 @@
* SWBuf::append - appends a value to the current value of this SWBuf
*/
void SWBuf::append(const char *str, const long max) {
+ if (!str) //A null string was passed
+ return;
//make sure we only copy strlen(str) bytes if max is larger than strlen(str) is
unsigned long str_len = strlen( str );
unsigned long len = (max > -1) ? ((max <= str_len) ? max : str_len) : str_len;
@@ -178,6 +180,9 @@
}
void SWBuf::insert(const unsigned long pos, const char* str, const signed long max) {
+ if (!str) //A null string was passed
+ return;
+
const int len = (max > -1) ? max : strlen(str);
if (!len || (pos > length())) //nothing to do, return
More information about the sword-cvs
mailing list