Closed Bug 204963 Opened 21 years ago Closed 9 years ago

memory leaks when PostEvent fails

Categories

(Core :: Networking, defect, P3)

defect

Tracking

()

RESOLVED WORKSFORME
mozilla1.5alpha

People

(Reporter: darin.moz, Unassigned)

Details

(Keywords: memory-leak)

there are a lot of places in necko and xpcom and probably others where errors
from PostEvent are not properly handled.  often times there is code like this:

  PLEvent *ev = new PLEvent;
  //...
  PL_InitEvent(ev, ...);
  
  if (eventQueue->PostEvent(ev) != PR_SUCCESS) {
    delete ev;
  }

on the surface this seems right, since the PLEvent was allocated using operator
new, but actually PL_InitEvent allocates other objects and hangs them off of the
PLEvent structure.  since PLEvent does not have a destructor, those allocates
are leaked when delete is used to cleanup the PLEvent.  the proper way to free a
PLEvent is to call PL_DestroyEvent.

i'm probably to blame for most of these leaks! ;-)

  ... but fortunately they should only really occur at shutdown.
Status: NEW → ASSIGNED
Priority: -- → P3
Target Milestone: --- → mozilla1.5alpha
over to me.
Assignee: darin → dougt
Status: ASSIGNED → NEW
this seems to be low-hanging fruit
mass reassigning to nobody.
Assignee: dougt → nobody
the necko post events look sane to me now.. generally they all use reference counted objects that do the right thing
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.