summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Hudson-Doyle <michael.hudson@linaro.org>2014-01-23 11:30:29 +1300
committerBenety Goh <benety@mongodb.com>2014-05-12 12:01:10 -0400
commitf0596feddd0ffb4ffcb379371d03d0f44e516d0e (patch)
tree27d2cc5eb043fc6748205cda1dc5bcb25c578d27 /src
parent251d119e685a89d7c7b494d9c6c0f0e3323849ba (diff)
downloadmongo-f0596feddd0ffb4ffcb379371d03d0f44e516d0e.tar.gz
SERVER-12461 Ensure LexNumCmp::cmp only returns 1, -1 or 0
strncmp's documentation says: It returns an integer less than, equal to, or greater than zero if s1 is found, respectively, to be less than, to match, or be greater than s2. LexNumCmp::cmp is tested as returning only -1, 1 or 0 but returns the return value of strncmp directly. This changes it to clamp the return value to -1, 1 or 0. Signed-off-by: Benety Goh <benety@mongodb.com>
Diffstat (limited to 'src')
-rw-r--r--src/mongo/util/stringutils.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/mongo/util/stringutils.cpp b/src/mongo/util/stringutils.cpp
index 857dac9d4c4..838a9ba3cb9 100644
--- a/src/mongo/util/stringutils.cpp
+++ b/src/mongo/util/stringutils.cpp
@@ -107,7 +107,7 @@ namespace mongo {
sd2.rawData() + s2,
len1 );
if ( result )
- return result;
+ return ( result > 0) ? 1 : -1;
}
// otherwise, the numbers are equal