@@ -37,7 +37,7 @@ namespace __hwasan {
37
37
38
38
class ScopedReport {
39
39
public:
40
- ScopedReport (bool fatal = false ) : error_message_( 1 ), fatal(fatal) {
40
+ ScopedReport (bool fatal = false ) : fatal(fatal) {
41
41
Lock lock (&error_message_lock_);
42
42
error_message_ptr_ = fatal ? &error_message_ : nullptr ;
43
43
++hwasan_report_count;
@@ -65,11 +65,7 @@ class ScopedReport {
65
65
Lock lock (&error_message_lock_);
66
66
if (!error_message_ptr_)
67
67
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);
73
69
}
74
70
75
71
static void SetErrorReportCallback (void (*callback)(const char *)) {
@@ -78,17 +74,17 @@ class ScopedReport {
78
74
}
79
75
80
76
private:
81
- InternalMmapVector< char > error_message_;
77
+ InternalScopedString error_message_;
82
78
bool fatal;
83
79
84
80
static Mutex error_message_lock_;
85
- static InternalMmapVector< char > *error_message_ptr_
81
+ static InternalScopedString *error_message_ptr_
86
82
SANITIZER_GUARDED_BY (error_message_lock_);
87
83
static void (*error_report_callback_)(const char *);
88
84
};
89
85
90
86
Mutex ScopedReport::error_message_lock_;
91
- InternalMmapVector< char > *ScopedReport::error_message_ptr_;
87
+ InternalScopedString *ScopedReport::error_message_ptr_;
92
88
void (*ScopedReport::error_report_callback_)(const char *);
93
89
94
90
// If there is an active ScopedReport, append to its error message.
0 commit comments