aboutsummaryrefslogtreecommitdiff
path: root/lib/libkse
diff options
context:
space:
mode:
authorJason Evans <jasone@FreeBSD.org>2000-05-16 22:08:14 +0000
committerJason Evans <jasone@FreeBSD.org>2000-05-16 22:08:14 +0000
commitccb3a748f4e1f9dfb843048a0ce1347c28af69cd (patch)
tree9c57126aed41ce52bc7bab304ca7a7595f5d2137 /lib/libkse
parent9ee6ec34efb08899038548ab6b5f367d8d1133fb (diff)
downloadsrc-ccb3a748f4e1f9dfb843048a0ce1347c28af69cd.tar.gz
src-ccb3a748f4e1f9dfb843048a0ce1347c28af69cd.zip
Fix a memory leak. pthread_set_name_np() allocates space for a name, but
was not deallocating space for the previous name, if any. PR: misc/18504
Notes
Notes: svn path=/head/; revision=60658
Diffstat (limited to 'lib/libkse')
-rw-r--r--lib/libkse/thread/thr_info.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/libkse/thread/thr_info.c b/lib/libkse/thread/thr_info.c
index 06b556e69b18..d091ec12113c 100644
--- a/lib/libkse/thread/thr_info.c
+++ b/lib/libkse/thread/thr_info.c
@@ -304,8 +304,12 @@ void
pthread_set_name_np(pthread_t thread, char *name)
{
/* Check if the caller has specified a valid thread: */
- if (thread != NULL && thread->magic == PTHREAD_MAGIC)
+ if (thread != NULL && thread->magic == PTHREAD_MAGIC) {
+ if (thread->name != NULL) {
+ /* Free space for previous name. */
+ free(thread->name);
+ }
thread->name = strdup(name);
- return;
+ }
}
#endif