Closed
Bug 21768
Opened 25 years ago
Closed 25 years ago
nsHTMLButtonElement::SetForm(null) leaks form
Categories
(Core :: Layout: Form Controls, defect, P3)
Core
Layout: Form Controls
Tracking
()
VERIFIED
FIXED
M13
People
(Reporter: pollmann, Assigned: pollmann)
Details
(Whiteboard: [patch] [DONTTEST])
This leak found by Brian Ryner <bryner@uiuc.edu>:
Brian Ryner wrote:
> Hi-
>
> Not sure if you're the person for this but you were the last person to
> touch nsHTMLButtonElement.cpp::SetForm. I'm looking into some leaks of
> nsHTMLFormElement and it looks to me like the reference that's added
> from the second QueryInterface in this method (with the comment "keep
> the ref") is never released. At first I thought the nsHTMLButtonElement
> was being leaked, but that's not the case... so now I believe that
> SetForm(NULL) is being called, and leaking the previous value of mForm.
> Do you know how this code is supposed to work?
>
> Thanks.
>
> --
> -Brian Ryner
> bryner@uiuc.edu
Quick fix I came up with is:
Index: nsHTMLButtonElement.cpp
===================================================================
RCS file: /cvsroot/mozilla/layout/html/content/src/nsHTMLButtonElement.cpp,v
retrieving revision 1.35
diff -c -r1.35 nsHTMLButtonElement.cpp
*** nsHTMLButtonElement.cpp 1999/12/04 02:22:19 1.35
--- nsHTMLButtonElement.cpp 1999/12/15 01:08:22
***************
*** 521,531 ****
nsHTMLButtonElement::SetForm(nsIDOMHTMLFormElement* aForm)
{
nsresult result = NS_OK;
if (nsnull == aForm) {
mForm = nsnull;
return NS_OK;
} else {
- NS_IF_RELEASE(mForm);
nsIFormControl* formControl = nsnull;
result = QueryInterface(kIFormControlIID, (void**)&formControl);
if ((NS_OK == result) && formControl) {
--- 521,531 ----
nsHTMLButtonElement::SetForm(nsIDOMHTMLFormElement* aForm)
{
nsresult result = NS_OK;
+ NS_IF_RELEASE(mForm);
if (nsnull == aForm) {
mForm = nsnull;
return NS_OK;
} else {
nsIFormControl* formControl = nsnull;
result = QueryInterface(kIFormControlIID, (void**)&formControl);
if ((NS_OK == result) && formControl) {
Assignee | ||
Updated•25 years ago
|
Status: NEW → ASSIGNED
Target Milestone: M13
Assignee | ||
Updated•25 years ago
|
Whiteboard: [patch] no testcase needed
Updated•25 years ago
|
Whiteboard: [patch] no testcase needed → [patch] [DONTTEST]
Comment 1•25 years ago
|
||
Changed code to be [DONTTEST] for consistency.
Assignee | ||
Updated•25 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Assignee | ||
Comment 2•25 years ago
|
||
I just checked in my "quick fix" above with no changes. This prevents us from
leaking mForm even if we are setting it to null. This is a code level fix and
is not verifyable by running the program.
Changes are here:
http://cvs-mirror.mozilla.org/webtools/bonsai/cvsview2.cgi?diff_mode=context&whitespace_mode=show&subdir=mozilla/layout/html/content/src&command=DIFF_FRAMESET&file=nsHTMLButtonElement.cpp&rev1=1.35&rev2=1.36&root=/cvsroot
Thanks!
You need to log in
before you can comment on or make changes to this bug.
Description
•