[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

llvm-svn: 222025
This commit is contained in:
Eric Fiselier 2014-11-14 19:10:43 +00:00
parent 1cbb971c2d
commit 93f65c4d08
8 changed files with 8 additions and 0 deletions

View 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);
}

View File

@ -29,5 +29,6 @@ int main()
out << 'a';
out << char(0);
assert(out.str() == std::string("a"));
out.freeze(false);
}
}

View 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);
}
}

View File

@ -31,4 +31,5 @@ int main()
assert(i == 123);
assert(d == 4.5);
assert(strcmp(s.c_str(), "dog") == 0);
inout.freeze(false);
}

View File

@ -29,5 +29,6 @@ int main()
out << 'a';
out << char(0);
assert(out.str() == std::string("a"));
out.freeze(false);
}
}

View 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);
}
}

View File

@ -27,5 +27,6 @@ int main()
assert(sb.pcount() == 2);
assert(sb.str() == std::string("a"));
assert(sb.pcount() == 2);
sb.freeze(false);
}
}

View 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);
}
}