summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2011-03-27 01:01:34 +0000
committerChris Wilson <chris+github@qwirx.com>2011-03-27 01:01:34 +0000
commit0fe90245a77295226d0967bc0702e591afe2afa7 (patch)
tree69b1402bac421520921513cf13ed06e2535e47ec /lib
parenta6ea3ec4d7f048ae16637532a1e9d7269b623eba (diff)
Fix off-by-one errors caught by MSVC.
Diffstat (limited to 'lib')
-rw-r--r--lib/common/FdGetLine.cpp9
-rw-r--r--lib/common/IOStreamGetLine.cpp9
2 files changed, 14 insertions, 4 deletions
diff --git a/lib/common/FdGetLine.cpp b/lib/common/FdGetLine.cpp
index 9b53288b..9add2bd1 100644
--- a/lib/common/FdGetLine.cpp
+++ b/lib/common/FdGetLine.cpp
@@ -185,8 +185,13 @@ std::string FdGetLine::GetLine(bool Preprocess)
{
begin++;
}
- if(!iw(r[end])) end--;
- while(end > begin && iw(r[end]))
+
+ if(end < size && !iw(r[end]))
+ {
+ end--;
+ }
+
+ while(end > begin && end < size && iw(r[end]))
{
end--;
}
diff --git a/lib/common/IOStreamGetLine.cpp b/lib/common/IOStreamGetLine.cpp
index 27a77c29..3e6612cb 100644
--- a/lib/common/IOStreamGetLine.cpp
+++ b/lib/common/IOStreamGetLine.cpp
@@ -168,8 +168,13 @@ bool IOStreamGetLine::GetLine(std::string &rOutput, bool Preprocess, int Timeout
{
begin++;
}
- if(!iw(r[end])) end--;
- while(end > begin && iw(r[end]))
+
+ if(end < size && !iw(r[end]))
+ {
+ end--;
+ }
+
+ while(end > begin && end < size && iw(r[end]))
{
end--;
}