[libcxx] r282468 - Fix possible division by zero

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 26 19:13:27 PDT 2016


Author: ericwf
Date: Mon Sep 26 21:13:27 2016
New Revision: 282468

URL: http://llvm.org/viewvc/llvm-project?rev=282468&view=rev
Log:
Fix possible division by zero

Modified:
    libcxx/trunk/src/experimental/filesystem/operations.cpp

Modified: libcxx/trunk/src/experimental/filesystem/operations.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/operations.cpp?rev=282468&r1=282467&r2=282468&view=diff
==============================================================================
--- libcxx/trunk/src/experimental/filesystem/operations.cpp (original)
+++ libcxx/trunk/src/experimental/filesystem/operations.cpp Mon Sep 26 21:13:27 2016
@@ -720,7 +720,7 @@ space_info __space(const path& p, std::e
     // 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);




More information about the cfe-commits mailing list