[sword-svn] r2024 - trunk/src/modules/common

scribe at www.crosswire.org scribe at www.crosswire.org
Fri Dec 8 14:49:17 MST 2006


Author: scribe
Date: 2006-12-08 14:49:17 -0700 (Fri, 08 Dec 2006)
New Revision: 2024

Modified:
   trunk/src/modules/common/zverse.cpp
Log:
Not sure how this zverse code works, but here are a few comments:
1) I don't mind the check for valid start/end values, as long as we don't suffer a performance hit.
2) Since I don't understand the code, but it has worked fine with valid parameters for a long time,
  this current commit returns the code logic back to what it was before and allows for the check.
3) If the previous logic change was correct (i.e. (start+size) <= strlen(cacheBuf)), which I can't confirm
without a thoughout evaluation of the rest of the code and don't have time for this right now... then the subsequent strncpy
and setSize(strlen...  checks were not needed (strncpy -> memcpy, and no setSize), since we already knew from the added strlen that we wouldn't hit a null.

This change puts the logic back to the way it has been for a long time, working with proper values,
adds a check for improper start value, (size value is insignificant with strncpy)
And still doesn't explain WHY we are getting INVALID VALUES passed when an incorrect key is used.
I suspect the invalid params means we still have a problem lingering somewhere.



Modified: trunk/src/modules/common/zverse.cpp
===================================================================
--- trunk/src/modules/common/zverse.cpp	2006-12-08 16:06:19 UTC (rev 2023)
+++ trunk/src/modules/common/zverse.cpp	2006-12-08 21:49:17 UTC (rev 2024)
@@ -256,7 +256,7 @@
 
 void zVerse::zReadText(char testmt, long start, unsigned short size, SWBuf &inBuf) {
 	inBuf = "";
-	if ( (size > 0) && cacheBuf && ((unsigned)(start+size) <= strlen(cacheBuf)) ){ //TODO: optimize this, remove strlen
+	if ( (size > 0) && cacheBuf && ((unsigned)start < strlen(cacheBuf)) ){ //TODO: optimize this, remove strlen
 		inBuf.setFillByte(0);
 		inBuf.setSize(size+1);
 		strncpy(inBuf.getRawData(), &(cacheBuf[start]), size);




More information about the sword-cvs mailing list