From 0c0843ee5ccb3f63c49a7656ae2c80c28020726f Mon Sep 17 00:00:00 2001
From: dt
Date: Mon, 30 Aug 1999 15:45:42 +0000
Subject: [PATCH] Fix a memory leak: free the thread-specific poll_data, used
in the select() implementation.
PR: 13368
Submitted by: Steve Bernacki, Jr.
---
lib/libc_r/uthread/uthread_exit.c | 6 ++++++
lib/libkse/thread/thr_exit.c | 6 ++++++
lib/libpthread/thread/thr_exit.c | 6 ++++++
3 files changed, 18 insertions(+)
diff --git a/lib/libc_r/uthread/uthread_exit.c b/lib/libc_r/uthread/uthread_exit.c
index c9894435748d..795decce0b4f 100644
--- a/lib/libc_r/uthread/uthread_exit.c
+++ b/lib/libc_r/uthread/uthread_exit.c
@@ -134,6 +134,12 @@ pthread_exit(void *status)
_thread_cleanupspecific();
}
+ /* Free thread-specific poll_data structure, if allocated */
+ if (_thread_run->poll_data.fds != NULL) {
+ free(_thread_run->poll_data.fds);
+ _thread_run->poll_data.fds = NULL;
+ }
+
/*
* Defer signals to protect the scheduling queues from access
* by the signal handler:
diff --git a/lib/libkse/thread/thr_exit.c b/lib/libkse/thread/thr_exit.c
index c9894435748d..795decce0b4f 100644
--- a/lib/libkse/thread/thr_exit.c
+++ b/lib/libkse/thread/thr_exit.c
@@ -134,6 +134,12 @@ pthread_exit(void *status)
_thread_cleanupspecific();
}
+ /* Free thread-specific poll_data structure, if allocated */
+ if (_thread_run->poll_data.fds != NULL) {
+ free(_thread_run->poll_data.fds);
+ _thread_run->poll_data.fds = NULL;
+ }
+
/*
* Defer signals to protect the scheduling queues from access
* by the signal handler:
diff --git a/lib/libpthread/thread/thr_exit.c b/lib/libpthread/thread/thr_exit.c
index c9894435748d..795decce0b4f 100644
--- a/lib/libpthread/thread/thr_exit.c
+++ b/lib/libpthread/thread/thr_exit.c
@@ -134,6 +134,12 @@ pthread_exit(void *status)
_thread_cleanupspecific();
}
+ /* Free thread-specific poll_data structure, if allocated */
+ if (_thread_run->poll_data.fds != NULL) {
+ free(_thread_run->poll_data.fds);
+ _thread_run->poll_data.fds = NULL;
+ }
+
/*
* Defer signals to protect the scheduling queues from access
* by the signal handler: