summaryrefslogtreecommitdiffstats
path: root/vm/Thread.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2012-01-06 17:25:14 -0800
committerElliott Hughes <enh@google.com>2012-04-19 15:06:02 -0700
commit7e2f0ea6e610787e628635f020b5b6f4e90b59f5 (patch)
tree5ed405a2d374fb4db79d1709840b05052b5d0b34 /vm/Thread.cpp
parent2a3cc744730ec76a05b31df8ac5b6de538d6d70b (diff)
downloadandroid_dalvik-7e2f0ea6e610787e628635f020b5b6f4e90b59f5.tar.gz
android_dalvik-7e2f0ea6e610787e628635f020b5b6f4e90b59f5.tar.bz2
android_dalvik-7e2f0ea6e610787e628635f020b5b6f4e90b59f5.zip
Fix a small memory leak.
Found by someone reading the code, rather than because we saw a crash. This is only a small leak, and you'd have to be dumping threads (because of an ANR) or creating a new thread to provoke it. (cherry picked from commit 6d1a1dfd0ef006e19067b6ffd927160d0c6d9647) Change-Id: Id857efca8d34b20d1acaa452c3fe5d2975e2572b
Diffstat (limited to 'vm/Thread.cpp')
-rw-r--r--vm/Thread.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/vm/Thread.cpp b/vm/Thread.cpp
index 5122adfad..8e879e084 100644
--- a/vm/Thread.cpp
+++ b/vm/Thread.cpp
@@ -3340,7 +3340,10 @@ std::string dvmGetThreadName(Thread* thread) {
StringObject* nameObj = (StringObject*)
dvmGetFieldObject(thread->threadObj, gDvm.offJavaLangThread_name);
- return dvmCreateCstrFromString(nameObj);
+ char* name = dvmCreateCstrFromString(nameObj);
+ std::string result(name);
+ free(name);
+ return result;
}
/*