Closed
Bug 95902
Opened 24 years ago
Closed 24 years ago
missing return NS_OK and memory leak if SetMediaText fails
Categories
(Core :: CSS Parsing and Computation, defect)
Core
CSS Parsing and Computation
Tracking
()
RESOLVED
FIXED
People
(Reporter: drepper, Assigned: bzbarsky)
References
Details
Attachments
(1 file)
|
556 bytes,
patch
|
Details | Diff | Splinter Review |
I just saw that the compiler is complaining about a missing return
incontent/html/style/src/nsCSSStyleSheet.cpp. I'll attach a patch.
| Reporter | ||
Comment 1•24 years ago
|
||
Comment 3•24 years ago
|
||
rubber-r=hwaara
r=dbaron, but while we're there, could we change the
NS_ENSURE_ARG_POINTER(aInstancePtrResult);
to
NS_ASSERTION(aInstancePtrResult, "null out param");
since we don't need to null-check out params in release builds.
We should probably also set *aInstancePtrResult to null for the error returns
(all 3, if the first one is removed).
Actually, we also leak on failure if SetMediaList fails. Maybe the function
should read:
nsresult
NS_NewMediaList(nsIMediaList** aInstancePtrResult, const nsAReadableString&
aMediaText) {
nsresult rv;
NS_ASSERTION(aInstancePtrResult, "null out param");
nsCOMPtr<nsISupportsArray> array;
rv = NS_NewISupportsArray(getter_AddRefs(array));
if (NS_FAILED(rv)) {
*aInstancePtrResult = nsnull;
return NS_ERROR_OUT_OF_MEMORY;
}
DOMMediaListImpl* medialist = new DOMMediaListImpl(array, nsnull);
if (!mediaList) {
*aInstancePtrResult = nsnull;
return NS_ERROR_OUT_OF_MEMORY;
}
NS_ADDREF(*aInstancePtrResult = mediaList);
rv = medialist->SetMediaText(aMediaText);
if (NS_FAILED(rv))
NS_RELEASE(*aInstancePtrResult);
return rv;
}
although I hesitate to waste that much code on checking for out-of-memory when
we'd probably crash miserably elsewhere.
| Assignee | ||
Comment 7•24 years ago
|
||
This will be fixed as part of the patch in bug 93977, since I'm touching a lot
of this code there anyway...
Depends on: 93977
| Assignee | ||
Comment 9•24 years ago
|
||
True. I should clarify that the fix for the leak when SetMediaText fails is in
my patch for bug 93977. The fix for the NS_OK was already in there before this
got filed. :)
So let's keep this open till one or the other gets checked in.
Summary: missing return NS_OK → missing return NS_OK and memory leak if SetMediaText fails
| Assignee | ||
Comment 10•24 years ago
|
||
fixed by checkin for bug 93977
Status: NEW → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•