From c91e786fa18e9e2bb58774da4a4aa1891625e57b Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 13 Aug 2009 18:38:15 +0000 Subject: [PATCH] Add an assert to check copy_to_buffer's precondition. llvm-svn: 78926 --- lib/Support/raw_ostream.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/Support/raw_ostream.cpp b/lib/Support/raw_ostream.cpp index 5eaf7bf6a04..3ea5c9af835 100644 --- a/lib/Support/raw_ostream.cpp +++ b/lib/Support/raw_ostream.cpp @@ -222,6 +222,8 @@ raw_ostream &raw_ostream::write(const char *Ptr, size_t Size) { } void raw_ostream::copy_to_buffer(const char *Ptr, size_t Size) { + assert(Size <= OutBufEnd - OutBufCur && "Buffer overrun!"); + // Handle short strings specially, memcpy isn't very good at very short // strings. switch (Size) {