Marshall Clow found this memory problem in strstream using -fsanitize=address on the test suite.

llvm-svn: 177452
This commit is contained in:
Howard Hinnant 2013-03-19 22:16:57 +00:00
parent 640986bed9
commit 4bb98d0917
1 changed files with 2 additions and 0 deletions

View File

@ -158,6 +158,8 @@ strstreambuf::overflow(int_type __c)
return int_type(EOF); return int_type(EOF);
streamsize old_size = (epptr() ? epptr() : egptr()) - eback(); streamsize old_size = (epptr() ? epptr() : egptr()) - eback();
streamsize new_size = max<streamsize>(__alsize_, 2*old_size); streamsize new_size = max<streamsize>(__alsize_, 2*old_size);
if (new_size == 0)
new_size = __default_alsize;
char* buf = nullptr; char* buf = nullptr;
if (__palloc_) if (__palloc_)
buf = static_cast<char*>(__palloc_(static_cast<size_t>(new_size))); buf = static_cast<char*>(__palloc_(static_cast<size_t>(new_size)));