summaryrefslogtreecommitdiff
path: root/src/mongo/db/storage/key_string.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/storage/key_string.cpp')
-rw-r--r--src/mongo/db/storage/key_string.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/mongo/db/storage/key_string.cpp b/src/mongo/db/storage/key_string.cpp
index 908bd51908a..b9c0d7c3fdf 100644
--- a/src/mongo/db/storage/key_string.cpp
+++ b/src/mongo/db/storage/key_string.cpp
@@ -281,7 +281,7 @@ StringData readCStringWithNuls(BufReader* reader, std::string* scratch) {
return initial; // Don't alloc or copy for simple case with no NUL bytes.
scratch->append(initial.rawData(), initial.size());
- while (reader->peek<unsigned char>() == 0xFF) {
+ while (reader->remaining() && reader->peek<unsigned char>() == 0xFF) {
// Each time we enter this loop it means we hit a NUL byte encoded as "\x00\xFF".
*scratch += '\0';
reader->skip(1);