summaryrefslogtreecommitdiffstats
path: root/libcxx/src
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2013-03-19 22:16:57 +0000
committerHoward Hinnant <hhinnant@apple.com>2013-03-19 22:16:57 +0000
commit4bb98d0917076f644557c1deb0c52f261bac7a43 (patch)
tree7472c58684c6ace30c7a27de9d0766f4c8bc3f59 /libcxx/src
parent640986bed90bb6064a99411ea6147618b1241e9b (diff)
downloadbcm5719-llvm-4bb98d0917076f644557c1deb0c52f261bac7a43.tar.gz
bcm5719-llvm-4bb98d0917076f644557c1deb0c52f261bac7a43.zip
Marshall Clow found this memory problem in strstream using -fsanitize=address on the test suite.
llvm-svn: 177452
Diffstat (limited to 'libcxx/src')
-rw-r--r--libcxx/src/strstream.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/libcxx/src/strstream.cpp b/libcxx/src/strstream.cpp
index 8cd19e6a353..518422bd242 100644
--- a/libcxx/src/strstream.cpp
+++ b/libcxx/src/strstream.cpp
@@ -158,6 +158,8 @@ strstreambuf::overflow(int_type __c)
return int_type(EOF);
streamsize old_size = (epptr() ? epptr() : egptr()) - eback();
streamsize new_size = max<streamsize>(__alsize_, 2*old_size);
+ if (new_size == 0)
+ new_size = __default_alsize;
char* buf = nullptr;
if (__palloc_)
buf = static_cast<char*>(__palloc_(static_cast<size_t>(new_size)));
OpenPOWER on IntegriCloud