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

llvm-svn: 308880
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: e5cc2fcc9037b5eab7cb5250915002171f41d137
diff --git a/include/streambuf b/include/streambuf
index a10ce1b..f6182d6 100644
--- a/include/streambuf
+++ b/include/streambuf
@@ -404,7 +404,8 @@
     {
         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;