Closed Bug 1247933 Opened 4 years ago Closed 4 years ago

[Static Analysis][Dereference before null check] In function MediaSystemResourceManager::AcquireSyncNoWait

Categories

(Core :: Audio/Video, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla47
Tracking Status
firefox47 --- fixed

People

(Reporter: andi, Assigned: andi)

References

(Blocks 1 open bug)

Details

(Keywords: coverity, Whiteboard: CID 1311563 )

Attachments

(1 file)

The Static Analysis tool Coverity added that a possible null pointer dereference on aClient can happen in the code below:

>>    MOZ_ASSERT(client == aClient);
>>
>>    aClient->mIsSync = true; // sync request
>>
>>    if (InImageBridgeChildThread()) {

the thing that confuses Coverity is the following null check done on aClient:

>>    if (!aClient ||
>>        !client ||
>>        client != aClient) {
>>      HandleAcquireResult(aClient->mId, false);
>>      return false;
>>    }

checking aClinet against null is useless since in this context aClient is called as this from MediaSystemResourceClient::AcquireSyncNoWait:

>>bool
>>MediaSystemResourceClient::AcquireSyncNoWait()
>>{
>>  if (!mManager) {
>>    return false;
>>  }
>>  return mManager->AcquireSyncNoWait(this);
>>}

So we are safe to eliminate the aClinet check from AcquireSyncNoWait
Comment on attachment 8718833 [details]
MozReview Request: Bug 1247933 - do not perform null check on aClient since we know for sure it's a valid pointert. r?sotaro

Sotaro wrote this code, so I'll let him review this patch.
Attachment #8718833 - Flags: review?(cpearce) → review?(sotaro.ikeda.g)
Comment on attachment 8718833 [details]
MozReview Request: Bug 1247933 - do not perform null check on aClient since we know for sure it's a valid pointert. r?sotaro

Looks good. But I could not update review status in Review Board:-( It seems that I am not set as a reviewer.
Attachment #8718833 - Flags: review?(sotaro.ikeda.g) → review+
Comment on attachment 8718833 [details]
MozReview Request: Bug 1247933 - do not perform null check on aClient since we know for sure it's a valid pointert. r?sotaro

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/34781/diff/1-2/
Attachment #8718833 - Attachment description: MozReview Request: Bug 1247933 - do not perform null check on aClient since we know for sure it's a valid pointert. r?cpearce → MozReview Request: Bug 1247933 - do not perform null check on aClient since we know for sure it's a valid pointert. r?sotaro
Attachment #8718833 - Flags: review+ → review?(sotaro.ikeda.g)
i' ve updated the patch making you the reviewer, now everything should be OK.
Comment on attachment 8718833 [details]
MozReview Request: Bug 1247933 - do not perform null check on aClient since we know for sure it's a valid pointert. r?sotaro

https://reviewboard.mozilla.org/r/34781/#review31599

Looks good.
Attachment #8718833 - Flags: review?(sotaro.ikeda.g) → review+
https://hg.mozilla.org/mozilla-central/rev/e0fc9144713e
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla47
You need to log in before you can comment on or make changes to this bug.