diff options
Diffstat (limited to 'src/mongo/base/string_data-inl.h')
-rw-r--r-- | src/mongo/base/string_data-inl.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/mongo/base/string_data-inl.h b/src/mongo/base/string_data-inl.h index a99a78d230e..00b403a569c 100644 --- a/src/mongo/base/string_data-inl.h +++ b/src/mongo/base/string_data-inl.h @@ -91,7 +91,8 @@ namespace mongo { if ( pos > size() ) throw std::out_of_range( "out of range" ); - if ( pos + n > size() ) + // truncate to end of string + if ( n > size() - pos ) n = size() - pos; return StringData( _data + pos, n ); |