diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/storage/flow_control.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/mongo/db/storage/flow_control.cpp b/src/mongo/db/storage/flow_control.cpp index 6c7d1bd7376..18642c49e10 100644 --- a/src/mongo/db/storage/flow_control.cpp +++ b/src/mongo/db/storage/flow_control.cpp @@ -54,6 +54,11 @@ const auto getFlowControl = ServiceContext::declareDecoration<std::unique_ptr<Fl const int kMaxTickets = 1000 * 1000 * 1000; int multiplyWithOverflowCheck(double term1, double term2, int maxValue) { + if (term1 == 0.0 || term2 == 0.0) { + // Early return to avoid any divide by zero errors. + return 0; + } + if (static_cast<double>(std::numeric_limits<int>::max()) / term2 < term1) { // Multiplying term1 and term2 would overflow, return maxValue. return maxValue; |