Closed
Bug 186725
Opened 22 years ago
Closed 22 years ago
nntp service NewURI doesn't check to see if SetSpec failed..
Categories
(MailNews Core :: Networking: NNTP, defect)
Tracking
(Not tracked)
VERIFIED
FIXED
People
(Reporter: timeless, Assigned: hamfastgamgee)
References
()
Details
Attachments
(1 file, 1 obsolete file)
2.37 KB,
patch
|
caillon
:
review+
darin.moz
:
superreview+
|
Details | Diff | Splinter Review |
i'm not sure how serious this is, but most implementations check.
Assignee | ||
Comment 1•22 years ago
|
||
This checks for success of the SetSpec call. It also de-tabs this particular
function (I figured I might as well do it while I was there).
Attachment #110160 -
Flags: superreview?(sspitzer)
Attachment #110160 -
Flags: review?(darin)
Comment 3•22 years ago
|
||
Comment on attachment 110160 [details] [diff] [review]
This fixes the issue
>Index: src/nsNntpService.cpp
>+ nsresult rv = NS_OK;
>
> nsCOMPtr <nsINntpUrl> nntpUrl = do_CreateInstance(NS_NNTPURL_CONTRACTID,&rv);
no reason to initialize rv since do_CreateInstance will always set rv.
> NS_ENSURE_SUCCESS(rv,rv);
> if (!nntpUrl) return NS_ERROR_FAILURE;
it should be sufficient to check rv. no need to null check nntpUrl (i know
this is existing code, but it would be good to clean it up while you're at it).
>
>- nntpUrl->QueryInterface(NS_GET_IID(nsIURI), (void **) _retval);
>+ nntpUrl->QueryInterface(NS_GET_IID(nsIURI), (void **) _retval);
nit, prefer:
rv = CallQueryInterface(nntpUrl, _retval);
if (NS_FAILED(rv)) return rv;
>+ rv = (*_retval)->SetSpec(aSpec);
>+ NS_ENSURE_SUCCESS(rv,rv);
>+ return rv;
this code potentially introduces a leak. the caller can rightfully do this:
nsIURI *uri;
rv = nntpService->NewURI(..., &uri);
if (NS_FAILED(rv)) return rv;
this code would cause the uri object to leak if SetSpec failed. so, you
should either use a COMPtr for the QueryInterface result or be sure to
call NS_RELEASE(*_retval) if SetSpec fails.
Attachment #110160 -
Flags: review?(darin) → review-
Attachment #110160 -
Attachment is obsolete: true
*** Bug 186730 has been marked as a duplicate of this bug. ***
Updated•22 years ago
|
Attachment #110935 -
Flags: review+
Attachment #110935 -
Flags: superreview?(darin)
Comment 6•22 years ago
|
||
Comment on attachment 110935 [details] [diff] [review]
per darin
>Index: mozilla/mailnews/news/src/nsNntpService.cpp
>+ nsCOMPtr<nsINntpUrl> nntpUrl = do_CreateInstance(NS_NNTPURL_CONTRACTID, &rv);
> NS_ENSURE_SUCCESS(rv,rv);
> if (!nntpUrl) return NS_ERROR_FAILURE;
nit: eliminate redundant check.
with that sr=darin
Attachment #110935 -
Flags: superreview?(darin) → superreview+
checked in
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Comment 8•21 years ago
|
||
Verified via code inspection using LXR.
1.235 timeless%mozdev.org Jun 15 12:36 Bug 186725 nntp service NewURI doesn't
check to see if SetSpec failed..
r=caillon sr=darin
Status: RESOLVED → VERIFIED
Updated•21 years ago
|
Attachment #110160 -
Flags: superreview?(sspitzer)
Updated•20 years ago
|
Product: MailNews → Core
Updated•16 years ago
|
Product: Core → MailNews Core
You need to log in
before you can comment on or make changes to this bug.
Description
•