Author: ericwf
Date: Fri Nov 14 13:10:43 2014
New Revision: 222025

URL: http://llvm.org/viewvc/llvm-project?rev=222025&view=rev
Log:
[libcxx] Fix memory leak in strstream tests.

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

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

Modified: 
libcxx/trunk/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/default.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/default.pass.cpp?rev=222025&r1=222024&r2=222025&view=diff
==============================================================================
--- 
libcxx/trunk/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/default.pass.cpp
 (original)
+++ 
libcxx/trunk/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/default.pass.cpp
 Fri Nov 14 13:10:43 2014
@@ -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);
 }

Modified: 
libcxx/trunk/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/freeze.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/freeze.pass.cpp?rev=222025&r1=222024&r2=222025&view=diff
==============================================================================
--- 
libcxx/trunk/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/freeze.pass.cpp
 (original)
+++ 
libcxx/trunk/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/freeze.pass.cpp
 Fri Nov 14 13:10:43 2014
@@ -29,5 +29,6 @@ int main()
         out << 'a';
         out << char(0);
         assert(out.str() == std::string("a"));
+        out.freeze(false);
     }
 }

Modified: 
libcxx/trunk/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/str.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/str.pass.cpp?rev=222025&r1=222024&r2=222025&view=diff
==============================================================================
--- 
libcxx/trunk/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/str.pass.cpp
 (original)
+++ 
libcxx/trunk/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/str.pass.cpp
 Fri Nov 14 13:10:43 2014
@@ -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);
     }
 }

Modified: 
libcxx/trunk/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/default.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/default.pass.cpp?rev=222025&r1=222024&r2=222025&view=diff
==============================================================================
--- 
libcxx/trunk/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/default.pass.cpp
 (original)
+++ 
libcxx/trunk/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/default.pass.cpp
 Fri Nov 14 13:10:43 2014
@@ -31,4 +31,5 @@ int main()
     assert(i == 123);
     assert(d == 4.5);
     assert(strcmp(s.c_str(), "dog") == 0);
+    inout.freeze(false);
 }

Modified: 
libcxx/trunk/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/freeze.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/freeze.pass.cpp?rev=222025&r1=222024&r2=222025&view=diff
==============================================================================
--- 
libcxx/trunk/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/freeze.pass.cpp
 (original)
+++ 
libcxx/trunk/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/freeze.pass.cpp
 Fri Nov 14 13:10:43 2014
@@ -29,5 +29,6 @@ int main()
         out << 'a';
         out << char(0);
         assert(out.str() == std::string("a"));
+        out.freeze(false);
     }
 }

Modified: 
libcxx/trunk/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/str.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/str.pass.cpp?rev=222025&r1=222024&r2=222025&view=diff
==============================================================================
--- 
libcxx/trunk/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/str.pass.cpp
 (original)
+++ 
libcxx/trunk/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/str.pass.cpp
 Fri Nov 14 13:10:43 2014
@@ -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);
     }
 }

Modified: 
libcxx/trunk/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/pcount.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/pcount.pass.cpp?rev=222025&r1=222024&r2=222025&view=diff
==============================================================================
--- 
libcxx/trunk/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/pcount.pass.cpp
 (original)
+++ 
libcxx/trunk/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/pcount.pass.cpp
 Fri Nov 14 13:10:43 2014
@@ -27,5 +27,6 @@ int main()
         assert(sb.pcount() == 2);
         assert(sb.str() == std::string("a"));
         assert(sb.pcount() == 2);
+        sb.freeze(false);
     }
 }

Modified: 
libcxx/trunk/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/str.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/str.pass.cpp?rev=222025&r1=222024&r2=222025&view=diff
==============================================================================
--- 
libcxx/trunk/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/str.pass.cpp
 (original)
+++ 
libcxx/trunk/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/str.pass.cpp
 Fri Nov 14 13:10:43 2014
@@ -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);
     }
 }


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to