Closed Bug 1226144 Opened 9 years ago Closed 9 years ago

[Presentation API] Free sessionId before using it

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla45
blocking-b2g 2.5+
Tracking Status
firefox45 --- fixed
b2g-v2.5 --- fixed
b2g-master --- fixed

People

(Reporter: chunmin, Assigned: chunmin)

Details

(Whiteboard: [ft:conndevices])

Attachments

(2 files, 2 obsolete files)

>PresentationIPCService::MonitorResponderLoading(const nsAString& aSessionId,
>                                                nsIDocShell* aDocShell)
>{
>  MOZ_ASSERT(NS_IsMainThread());
> 
>  mCallback = new PresentationResponderLoadingCallback(aSessionId);
>  return mCallback->Init(aDocShell);
>}

>PresentationIPCService::NotifyReceiverReady(const nsAString& aSessionId,
>                                            uint64_t aWindowId)
>{
>  ...
>  ...
>  mCallback = nullptr;
>  NS_WARN_IF(!sPresentationChild->SendNotifyReceiverReady(nsAutoString(aSessionId)));
>  return NS_OK;
>}

The |aSessionId| passed into |SendNotifyReceiverReady|[1] is holded by |PresentationCallbacks|, which is created in PresentationIPCService::MonitorResponderLoading.

|mCallback = nullptr|[4] above will free the |PresentationCallbacks| and lose |aSessionId| before it's passed into |SendNotifyReceiverReady|[1]

[1] https://dxr.mozilla.org/mozilla-central/source/dom/presentation/ipc/PresentationIPCService.cpp#258
[2] https://dxr.mozilla.org/mozilla-central/source/dom/presentation/PresentationCallbacks.h#61
[3] https://dxr.mozilla.org/mozilla-central/source/dom/presentation/ipc/PresentationIPCService.cpp#287
[4] https://dxr.mozilla.org/mozilla-central/source/dom/presentation/ipc/PresentationIPCService.cpp#257
Attached file raw gdb log
Hi, Sean,
I was wondering if you could review this small modification
Assignee: nobody → cchang
Attachment #8689949 - Flags: review?(selin)
Comment on attachment 8689949 [details] [diff] [review]
Free presentation sessionId after using it

Review of attachment 8689949 [details] [diff] [review]:
-----------------------------------------------------------------

It looks good to me. Thanks for taking this.

::: dom/presentation/ipc/PresentationIPCService.cpp
@@ +257,2 @@
>    NS_WARN_IF(!sPresentationChild->SendNotifyReceiverReady(nsAutoString(aSessionId)));
> +  mCallback = nullptr;

nit: please add a comment briefly describing why we need to do so. Then it's less likely that someone would make similar mistakes.
Attachment #8689949 - Flags: review?(selin) → review+
Adding a brief comment and carry r+
Attachment #8689949 - Attachment is obsolete: true
Attachment #8692450 - Flags: review+
Keywords: checkin-needed
Keywords: checkin-needed
fix typo
Attachment #8692450 - Attachment is obsolete: true
Attachment #8692459 - Flags: review+
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/8a4ed7c96ea4
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla45
Comment on attachment 8692459 [details] [diff] [review]
bug 1226144 - Free sessionId after using it

NOTE: Please see https://wiki.mozilla.org/Release_Management/B2G_Landing to better understand the B2G approval process and landings.

[Approval Request Comment]
Bug caused by (feature/regressing bug #): bug 1069230
User impact if declined: send tab to TV might fail
Testing completed: yes
Risk to taking this patch (and alternatives if risky):  N/A
String or UUID changes made by this patch: N/A
Attachment #8692459 - Flags: approval‑mozilla‑b2g44?
blocking-b2g: --- → 2.5+
Whiteboard: [ft:conndevices]
Comment on attachment 8692459 [details] [diff] [review]
bug 1226144 - Free sessionId after using it

Approve for TV 2.5
Attachment #8692459 - Flags: approval‑mozilla‑b2g44? → approval‑mozilla‑b2g44+
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: