Closed
Bug 218671
Opened 21 years ago
Closed 21 years ago
If ipcThreadInit fails to create ipcThread then ipcTrans and ipcMonitor will leak
Categories
(Core :: IPC, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: timeless, Assigned: timeless)
References
()
Details
(Keywords: memory-leak)
Attachments
(1 file)
1.02 KB,
patch
|
darin.moz
:
review+
darin.moz
:
superreview+
|
Details | Diff | Splinter Review |
static PRStatus
ipcThreadInit(ipcTransport *transport)
{
...
NS_ADDREF(ipcTrans = transport); // <- can leak
ipcShutdown = PR_FALSE;
ipcMonitor = PR_NewMonitor(); // <- can leak
if (!ipcMonitor)
return PR_FAILURE; // <- leaks ipcTrans
// spawn message thread
ipcThread = PR_CreateThread(PR_USER_THREAD, ipcThreadFunc, NULL,
PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD,
PR_JOINABLE_THREAD, 0);
if (!ipcThread) {
NS_WARNING("thread creation failed");
return PR_FAILURE; // <- leaks ipcTrans and ipcMonitor
}
...
ipcTransport::Disconnect()
{
mHaveConnection = PR_FALSE;
if (ipcThread) // <- guard which is only reached
// after both assignments and an additional alloc
ipcThreadShutdown();
...
static PRStatus
ipcThreadShutdown()
{
if (PR_AtomicSet(&ipcShutdown, PR_TRUE) == PR_FALSE) {
LOG(("posting IPC_WM_SHUTDOWN message\n"));
PostMessage(ipcLocalHwnd, IPC_WM_SHUTDOWN, 0, 0);
}
LOG(("joining w/ message thread...\n"));
PR_JoinThread(ipcThread);
ipcThread = NULL;
//
// ok, now the message thread is dead
//
PR_DestroyMonitor(ipcMonitor); // <- unreachable release unless ipcThread
ipcMonitor = NULL;
NS_RELEASE(ipcTrans); // <- unreachable release unless ipcThread and ipcMonitor
Attachment #131094 -
Flags: superreview?(darin)
Attachment #131094 -
Flags: review?(darin)
Comment 2•21 years ago
|
||
Comment on attachment 131094 [details] [diff] [review]
try to avoid leaking
looks right, thanks timeless. r+sr=darin
Attachment #131094 -
Flags: superreview?(darin)
Attachment #131094 -
Flags: superreview+
Attachment #131094 -
Flags: review?(darin)
Attachment #131094 -
Flags: review+
bonsai indicates i checked this in
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Updated•16 years ago
|
QA Contact: carosendahl → ipc
You need to log in
before you can comment on or make changes to this bug.
Description
•