[libcxx] Fix memory leak in strstream tests.
authorEric Fiselier <eric@efcs.ca>
Fri, 14 Nov 2014 19:10:43 +0000 (19:10 +0000)
committerEric Fiselier <eric@efcs.ca>
Fri, 14 Nov 2014 19:10:43 +0000 (19:10 +0000)
Summary: The strstream function `str()` sets `freeze(true)`. When `freeze` is true the destructor is not allowed to free any dynamically allocated memory. The memory leak causes ASAN to fail on these tests. To ensure memory is deallocated `strstream.freeze(false)` is called at the end of the tests.

Reviewers: danalbert, mclow.lists

Reviewed By: mclow.lists

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D6261

llvm-svn: 222025

libcxx/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/default.pass.cpp
libcxx/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/freeze.pass.cpp
libcxx/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/str.pass.cpp
libcxx/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/default.pass.cpp
libcxx/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/freeze.pass.cpp
libcxx/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/str.pass.cpp
libcxx/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/pcount.pass.cpp
libcxx/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/str.pass.cpp

index 78343f8..5ea4988 100644 (file)
@@ -24,4 +24,5 @@ int main()
     std::string s("dog");
     out << i << ' ' << d << ' ' << s << std::ends;
     assert(out.str() == std::string("123 4.5 dog"));
+    out.freeze(false);
 }
index 9a5542a..9a7160f 100644 (file)
@@ -22,5 +22,6 @@ int main()
         std::ostrstream out;
         out << 123 << ' ' << 4.5 << ' ' << "dog" << std::ends;
         assert(out.str() == std::string("123 4.5 dog"));
+        out.freeze(false);
     }
 }
index 525073c..4734338 100644 (file)
@@ -29,5 +29,6 @@ int main()
         out << 'a';
         out << char(0);
         assert(out.str() == std::string("a"));
+        out.freeze(false);
     }
 }
index 4ac1c44..5c273dc 100644 (file)
@@ -22,5 +22,6 @@ int main()
         std::strstream out;
         out << 123 << ' ' << 4.5 << ' ' << "dog" << std::ends;
         assert(out.str() == std::string("123 4.5 dog"));
+        out.freeze(false);
     }
 }
index dce29c9..27de56f 100644 (file)
@@ -23,5 +23,6 @@ int main()
         assert(sb.sputc('a') == 'a');
         assert(sb.sputc(0) == 0);
         assert(sb.str() == std::string("a"));
+        sb.freeze(false);
     }
 }