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
std::string s("dog");
out << i << ' ' << d << ' ' << s << std::ends;
assert(out.str() == std::string("123 4.5 dog"));
+ out.freeze(false);
}
out << 'a';
out << char(0);
assert(out.str() == std::string("a"));
+ out.freeze(false);
}
}
std::ostrstream out;
out << 123 << ' ' << 4.5 << ' ' << "dog" << std::ends;
assert(out.str() == std::string("123 4.5 dog"));
+ out.freeze(false);
}
}
assert(i == 123);
assert(d == 4.5);
assert(strcmp(s.c_str(), "dog") == 0);
+ inout.freeze(false);
}
out << 'a';
out << char(0);
assert(out.str() == std::string("a"));
+ out.freeze(false);
}
}
std::strstream out;
out << 123 << ' ' << 4.5 << ' ' << "dog" << std::ends;
assert(out.str() == std::string("123 4.5 dog"));
+ out.freeze(false);
}
}
assert(sb.pcount() == 2);
assert(sb.str() == std::string("a"));
assert(sb.pcount() == 2);
+ sb.freeze(false);
}
}
assert(sb.sputc('a') == 'a');
assert(sb.sputc(0) == 0);
assert(sb.str() == std::string("a"));
+ sb.freeze(false);
}
}