summaryrefslogtreecommitdiff
path: root/src/mongo/platform
diff options
context:
space:
mode:
authorVincent Do <do.vincent@live.com>2016-05-18 16:00:10 -0400
committerVincent Do <vincent.do@mongodb.com>2016-05-27 10:31:19 -0400
commitba23c68f0bf0a594a4af7080900ea03bda133fa4 (patch)
tree37d2a1f38df2f00615c8898dc395a524c564eeb1 /src/mongo/platform
parent9b3fc54ceb6d1066e423f7c562c22de2f5c6480e (diff)
downloadmongo-ba23c68f0bf0a594a4af7080900ea03bda133fa4.tar.gz
SERVER-23703 Make NumberDecimal accepts only valid strings
Diffstat (limited to 'src/mongo/platform')
-rw-r--r--src/mongo/platform/decimal128.cpp8
-rw-r--r--src/mongo/platform/decimal128.h4
2 files changed, 11 insertions, 1 deletions
diff --git a/src/mongo/platform/decimal128.cpp b/src/mongo/platform/decimal128.cpp
index def39a899e9..d0af1ea5bb9 100644
--- a/src/mongo/platform/decimal128.cpp
+++ b/src/mongo/platform/decimal128.cpp
@@ -250,11 +250,17 @@ Decimal128::Decimal128(double doubleValue,
Decimal128::Decimal128(std::string stringValue, RoundingMode roundMode) {
std::uint32_t throwAwayFlag = 0;
+ *this = Decimal128(stringValue, &throwAwayFlag, roundMode);
+}
+
+Decimal128::Decimal128(std::string stringValue,
+ std::uint32_t* signalingFlags,
+ RoundingMode roundMode) {
std::unique_ptr<char[]> charInput(new char[stringValue.size() + 1]);
std::copy(stringValue.begin(), stringValue.end(), charInput.get());
charInput[stringValue.size()] = '\0';
BID_UINT128 dec128;
- dec128 = bid128_from_string(charInput.get(), roundMode, &throwAwayFlag);
+ dec128 = bid128_from_string(charInput.get(), roundMode, signalingFlags);
_value = libraryTypeToValue(dec128);
}
diff --git a/src/mongo/platform/decimal128.h b/src/mongo/platform/decimal128.h
index f347ec42f70..6fa6d6d3e2c 100644
--- a/src/mongo/platform/decimal128.h
+++ b/src/mongo/platform/decimal128.h
@@ -177,6 +177,10 @@ public:
*/
explicit Decimal128(std::string stringValue, RoundingMode roundMode = kRoundTiesToEven);
+ Decimal128(std::string stringValue,
+ std::uint32_t* signalingFlag,
+ RoundingMode roundMode = kRoundTiesToEven);
+
/**
* This function gets the inner Value struct storing a Decimal128 value.
*/