Marshall Clow found this memory problem in strstream using -fsanitize=address on the test suite.
llvm-svn: 177452
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: 4bb98d0917076f644557c1deb0c52f261bac7a43
diff --git a/src/strstream.cpp b/src/strstream.cpp
index 8cd19e6..518422b 100644
--- a/src/strstream.cpp
+++ b/src/strstream.cpp
@@ -158,6 +158,8 @@
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)));