Skip to content

ADAL- On Auth Cancel - Authentication context static delegate map holds callback class reference leading to memory leak #708

Closed
@naveen11aug

Description

@naveen11aug

When user cancels the auth flow, request (holding callback class) is not getting removed from the static mDelegateMap, leading to leak in the callback class. Below code gets executed on auth cancel scenario.

// User cancelled the flow by clicking back button or
// activating another activity
Logger.v(TAG, "User cancelled the flow RequestId:" + requestId
+ correlationInfo);
waitingRequestOnError(waitingRequest, requestId, new AuthenticationCancelError(
"User cancelled the flow RequestId:" + requestId + correlationInfo));

private void waitingRequestOnError(final AuthenticationRequestState waitingRequest,
int requestId, AuthenticationException exc) {

    if (waitingRequest != null && waitingRequest.mDelagete != null) {
        Logger.v(TAG, "Sending error to callback"
                + getCorrelationInfoFromWaitingRequest(waitingRequest));
        waitingRequest.mDelagete.onError(exc);
    }
    if (exc != null && exc.getCode() != ADALError.AUTH_FAILED_CANCELLED) {
        removeWaitingRequest(requestId);
    }
}

As you can see, In case of cancel, waiting request is not getting removed.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions