Use a fixed-size buffer for log messages

libc++'s implementation of ostrstream seems to have incorrect
range-checking and does some out-of-bounds reads and writes whenever a
resize is needed, which results in crashes on 10.7 (but not 10.9 for
unknown reasons).
This commit is contained in:
Thomas Goyne 2013-12-07 09:39:39 -08:00
parent f886237623
commit 23a21b33b1
2 changed files with 4 additions and 1 deletions

View file

@ -84,7 +84,9 @@ decltype(LogSink::messages) LogSink::GetMessages() const {
return ret;
}
Message::Message(const char *section, Severity severity, const char *file, const char *func, int line) {
Message::Message(const char *section, Severity severity, const char *file, const char *func, int line)
: msg(buffer, sizeof buffer)
{
sm.section = section;
sm.severity = severity;
sm.file = file;

View file

@ -139,6 +139,7 @@ public:
class Message {
std::ostrstream msg;
SinkMessage sm;
char buffer[2048];
public:
Message(const char *section, Severity severity, const char *file, const char *func, int line);