Skip to content

Commit

Permalink
Fix-up error message buffer allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
jblomer committed Jul 3, 2020
1 parent 2c46921 commit 4229268
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/base/src/TError.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void ErrorHandler(Int_t level, const char *location, const char *fmt, std::va_li
buf_size = n + 1;
if (buf != &(small_buf[0]))
delete[] buf;
buf = new char[buf_size];
buf_storage = buf = new char[buf_size];

// Try again with a sufficiently large buffer
va_copy(ap_copy, ap);
Expand Down
4 changes: 4 additions & 0 deletions core/base/test/TErrorTests.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,8 @@ TEST(TError, LongMessage) {

Info("location", "%s", longMessage.c_str());
EXPECT_EQ(longMessage, gTestLastMsg);

// Again, should reuse the now enlarged, thread-local heap-allocated buffer
Info("location", "%s", longMessage.c_str());
EXPECT_EQ(longMessage, gTestLastMsg);
}

0 comments on commit 4229268

Please sign in to comment.