[libcxx] r308880 - make sure that we don't call basic_streambuf::gbump with a value bigger than INT_MAX, since it only takes an int. Related to, but not quite the same as PR33725

Marshall Clow via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 24 07:05:10 PDT 2017


Author: marshall
Date: Mon Jul 24 07:05:10 2017
New Revision: 308880

URL: http://llvm.org/viewvc/llvm-project?rev=308880&view=rev
Log:
make sure that we don't call basic_streambuf::gbump with a value bigger than INT_MAX, since it only takes an int. Related to, but not quite the same as PR33725

Modified:
    libcxx/trunk/include/streambuf

Modified: libcxx/trunk/include/streambuf
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/streambuf?rev=308880&r1=308879&r2=308880&view=diff
==============================================================================
--- libcxx/trunk/include/streambuf (original)
+++ libcxx/trunk/include/streambuf Mon Jul 24 07:05:10 2017
@@ -404,7 +404,8 @@ basic_streambuf<_CharT, _Traits>::xsgetn
     {
         if (__ninp_ < __einp_)
         {
-            const streamsize __len = _VSTD::min(__einp_ - __ninp_, __n - __i);
+            const streamsize __len = _VSTD::min(static_cast<streamsize>(INT_MAX),
+                                _VSTD::min(__einp_ - __ninp_, __n - __i));
             traits_type::copy(__s, __ninp_, __len);
             __s +=  __len;
             __i +=  __len;




More information about the cfe-commits mailing list