summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTad Marshall <tad@10gen.com>2012-11-28 05:22:34 -0500
committerTad Marshall <tad@10gen.com>2012-11-28 07:44:08 -0500
commit2557e9af57142f8334330c956bdcc8fb1cf481ab (patch)
treec1cd3b12181c445e51b5592a3f641bdfef592763
parent46b277b8aaaca0643585db1f68f9f79d5390e813 (diff)
downloadmongo-2557e9af57142f8334330c956bdcc8fb1cf481ab.tar.gz
SERVER-7787 Do not read character before checking count
Change the order of tests in copyString32to8counted() to check the count of input characters before reading a possibly uninitialized character.
-rw-r--r--src/mongo/shell/linenoise_utf8.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/mongo/shell/linenoise_utf8.cpp b/src/mongo/shell/linenoise_utf8.cpp
index d906c9676f2..dc6224dc236 100644
--- a/src/mongo/shell/linenoise_utf8.cpp
+++ b/src/mongo/shell/linenoise_utf8.cpp
@@ -238,7 +238,7 @@ size_t copyString32to8counted( UChar8* dest8, const UChar32* source32, size_t ou
size_t outputUTF8ByteCount = 0;
if ( outputBufferSizeInBytes ) {
size_t reducedBufferSize = outputBufferSizeInBytes - 4;
- while ( *source32 && charCount-- && outputUTF8ByteCount < reducedBufferSize ) {
+ while ( charCount-- && *source32 && outputUTF8ByteCount < reducedBufferSize ) {
UChar32 c = *source32++;
if ( c <= 0x7F ) {
*dest8++ = c;