Fix possible division by zero

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@282468 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2016-09-27 02:13:27 +00:00
parent b81bbd204b
commit fbdbb36015

View File

@@ -720,7 +720,7 @@ space_info __space(const path& p, std::error_code *ec) {
// Multiply with overflow checking.
auto do_mult = [&](std::uintmax_t& out, std::uintmax_t other) {
out = other * m_svfs.f_frsize;
if (out / other != m_svfs.f_frsize || other == 0)
if (other == 0 || out / other != m_svfs.f_frsize)
out = static_cast<std::uintmax_t>(-1);
};
do_mult(si.capacity, m_svfs.f_blocks);