Skip to content

Commit 569b3f7

Browse files
committed
Copy the passed in name string into the os_thread structure and delete it in the destructor.
[email protected] Review URL: https://codereview.chromium.org/1475863002 .
1 parent 29b3e53 commit 569b3f7

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

runtime/vm/os_thread.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ OSThread::~OSThread() {
4444
}
4545
timeline_block_ = NULL;
4646
delete timeline_block_lock_;
47+
free(name_);
4748
}
4849

4950

runtime/vm/os_thread.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ class OSThread : public BaseThread {
7575
void set_name(const char* name) {
7676
ASSERT(OSThread::Current() == this);
7777
ASSERT(name_ == NULL);
78-
name_ = name;
78+
ASSERT(name != NULL);
79+
name_ = strdup(name);
7980
}
8081

8182
Mutex* timeline_block_lock() const {
@@ -202,7 +203,7 @@ class OSThread : public BaseThread {
202203
const ThreadId id_;
203204
const ThreadId join_id_;
204205
const ThreadId trace_id_; // Used to interface with tracing tools.
205-
const char* name_; // A name for this thread.
206+
char* name_; // A name for this thread.
206207

207208
Mutex* timeline_block_lock_;
208209
TimelineEventBlock* timeline_block_;

0 commit comments

Comments
 (0)