[Box Backup-commit] COMMIT r2802 - box/invisnet/vs2010/0.11/lib/common

subversion at boxbackup.org subversion at boxbackup.org
Tue Oct 26 21:10:44 BST 2010


Author: invisnet
Date: 2010-10-26 21:10:43 +0100 (Tue, 26 Oct 2010)
New Revision: 2802

Modified:
   box/invisnet/vs2010/0.11/lib/common/FdGetLine.cpp
Log:
Properly fix parsing so we stay within bounds.

Modified: box/invisnet/vs2010/0.11/lib/common/FdGetLine.cpp
===================================================================
--- box/invisnet/vs2010/0.11/lib/common/FdGetLine.cpp	2010-10-26 20:08:47 UTC (rev 2801)
+++ box/invisnet/vs2010/0.11/lib/common/FdGetLine.cpp	2010-10-26 20:10:43 UTC (rev 2802)
@@ -176,6 +176,9 @@
 	{
 		// Remove whitespace
 		size_t size = r.size();
+		if(0 == size)
+			return "";
+
 		size_t begin = 0;
 		while(begin < size && iw(r[begin]))
 		{
@@ -183,17 +186,17 @@
 		}
 		
 		// Check for comment char, but char before must be whitespace
+		if(r[begin] == '#')
+			return "";
+
 		size_t end = begin;
-		while(end < size)
+		while(++end < size)
 		{
-			if(r[end] == '#' && (end == 0 || (iw(r[end-1]))))
-			{
+			if(r[end] == '#' && iw(r[end-1]))
 				break;
-			}
-			end++;
 		}
 		
-		for(end--; end > begin && iw(r[end]); end--);
+		while(--end > begin && iw(r[end])) end--;
 		
 		// Return a sub string
 		return r.substr(begin, end - begin + 1);




More information about the Boxbackup-commit mailing list