aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/io/zero_copy_stream_impl.cc
diff options
context:
space:
mode:
authorGravatar kenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d>2008-11-07 18:38:13 +0000
committerGravatar kenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d>2008-11-07 18:38:13 +0000
commit8da400ed12284575895cf7d5e4425435d4e43c42 (patch)
treeeaf054444e2c425182bb88476dc6dfb8677252bd /src/google/protobuf/io/zero_copy_stream_impl.cc
parent32d0c3b85386b6a535cac78a0e7d6261e2e0fa3f (diff)
Fix bugs in zero_copy_stream_impl.
Patch from Frank Chu.
Diffstat (limited to 'src/google/protobuf/io/zero_copy_stream_impl.cc')
-rw-r--r--src/google/protobuf/io/zero_copy_stream_impl.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/google/protobuf/io/zero_copy_stream_impl.cc b/src/google/protobuf/io/zero_copy_stream_impl.cc
index b3e6bf2f..10071054 100644
--- a/src/google/protobuf/io/zero_copy_stream_impl.cc
+++ b/src/google/protobuf/io/zero_copy_stream_impl.cc
@@ -218,7 +218,8 @@ int CopyingInputStream::Skip(int count) {
char junk[4096];
int skipped = 0;
while (skipped < count) {
- int bytes = Read(junk, min(count, implicit_cast<int>(sizeof(junk))));
+ int bytes = Read(junk, min(count - skipped,
+ implicit_cast<int>(sizeof(junk))));
if (bytes <= 0) {
// EOF or read error.
return skipped;
@@ -757,7 +758,7 @@ LimitingInputStream::~LimitingInputStream() {
}
bool LimitingInputStream::Next(const void** data, int* size) {
- if (limit_ < 0) return false;
+ if (limit_ <= 0) return false;
if (!input_->Next(data, size)) return false;
limit_ -= *size;