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
This commit is contained in:
parent
9ee6ec34ef
commit
ccb3a748f4
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=60658
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user