Skip to content

Commit 77106b7

Browse files
committed
[NFC][hwasan] Use InternalScopedString in ScopedReport
1 parent 733b33b commit 77106b7

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

compiler-rt/lib/hwasan/hwasan_report.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace __hwasan {
3737

3838
class ScopedReport {
3939
public:
40-
ScopedReport(bool fatal = false) : error_message_(1), fatal(fatal) {
40+
ScopedReport(bool fatal = false) : fatal(fatal) {
4141
Lock lock(&error_message_lock_);
4242
error_message_ptr_ = fatal ? &error_message_ : nullptr;
4343
++hwasan_report_count;
@@ -65,11 +65,7 @@ class ScopedReport {
6565
Lock lock(&error_message_lock_);
6666
if (!error_message_ptr_)
6767
return;
68-
uptr len = internal_strlen(msg);
69-
uptr old_size = error_message_ptr_->size();
70-
error_message_ptr_->resize(old_size + len);
71-
// overwrite old trailing '\0', keep new trailing '\0' untouched.
72-
internal_memcpy(&(*error_message_ptr_)[old_size - 1], msg, len);
68+
error_message_ptr_->Append(msg);
7369
}
7470

7571
static void SetErrorReportCallback(void (*callback)(const char *)) {
@@ -78,17 +74,17 @@ class ScopedReport {
7874
}
7975

8076
private:
81-
InternalMmapVector<char> error_message_;
77+
InternalScopedString error_message_;
8278
bool fatal;
8379

8480
static Mutex error_message_lock_;
85-
static InternalMmapVector<char> *error_message_ptr_
81+
static InternalScopedString *error_message_ptr_
8682
SANITIZER_GUARDED_BY(error_message_lock_);
8783
static void (*error_report_callback_)(const char *);
8884
};
8985

9086
Mutex ScopedReport::error_message_lock_;
91-
InternalMmapVector<char> *ScopedReport::error_message_ptr_;
87+
InternalScopedString *ScopedReport::error_message_ptr_;
9288
void (*ScopedReport::error_report_callback_)(const char *);
9389

9490
// If there is an active ScopedReport, append to its error message.

0 commit comments

Comments
 (0)