summaryrefslogtreecommitdiffstats
path: root/lib/libpthread
diff options
context:
space:
mode:
authorjasone <jasone@FreeBSD.org>2000-05-16 22:08:14 +0000
committerjasone <jasone@FreeBSD.org>2000-05-16 22:08:14 +0000
commit28fde4831e337e9ba71dec7b314ca3b3e7c51fdf (patch)
tree47ee5faa35c4a4357f4e992cc9d1db0b374c8e40 /lib/libpthread
parent406f1714dbaea520814643504466a34dd4d78bad (diff)
downloadFreeBSD-src-28fde4831e337e9ba71dec7b314ca3b3e7c51fdf.zip
FreeBSD-src-28fde4831e337e9ba71dec7b314ca3b3e7c51fdf.tar.gz
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
Diffstat (limited to 'lib/libpthread')
-rw-r--r--lib/libpthread/thread/thr_info.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/libpthread/thread/thr_info.c b/lib/libpthread/thread/thr_info.c
index 06b556e..d091ec1 100644
--- a/lib/libpthread/thread/thr_info.c
+++ b/lib/libpthread/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
OpenPOWER on IntegriCloud