]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/common/bytestream.cpp
ICU-62107.0.1.tar.gz
[apple/icu.git] / icuSources / common / bytestream.cpp
index bfd7bded714d912b1c66056412170c97512cf45b..0d0e4dda39b088720d1d7e4e9df7b98caa858e4f 100644 (file)
@@ -45,6 +45,12 @@ void CheckedArrayByteSink::Append(const char* bytes, int32_t n) {
   if (n <= 0) {
     return;
   }
+  if (n > (INT32_MAX - appended_)) {
+    // TODO: Report as integer overflow, not merely buffer overflow.
+    appended_ = INT32_MAX;
+    overflowed_ = TRUE;
+    return;
+  }
   appended_ += n;
   int32_t available = capacity_ - size_;
   if (n > available) {