Skip to content

Commit 21f85d6

Browse files
authored
[flutter_appauth] Fixes null pointer exceptions when attempting to return a result for a null pending operation (MaikuB#109)
This situation can occur when too many operations are started at one time. Once one operation completes, there is no longer a pending operation so any operations that complete after will throw a null pointer exception.
1 parent ccf5582 commit 21f85d6

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

flutter_appauth/android/src/main/java/io/crossingthestreams/flutterappauth/FlutterAppauthPlugin.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,13 +344,17 @@ private void finishWithTokenError(AuthorizationException ex) {
344344

345345

346346
private void finishWithSuccess(Object data) {
347-
pendingOperation.result.success(data);
348-
pendingOperation = null;
347+
if (pendingOperation != null) {
348+
pendingOperation.result.success(data);
349+
pendingOperation = null;
350+
}
349351
}
350352

351353
private void finishWithError(String errorCode, String errorMessage) {
352-
pendingOperation.result.error(errorCode, errorMessage, null);
353-
pendingOperation = null;
354+
if (pendingOperation != null) {
355+
pendingOperation.result.error(errorCode, errorMessage, null);
356+
pendingOperation = null;
357+
}
354358
}
355359

356360
private void finishWithDiscoveryError(AuthorizationException ex) {

0 commit comments

Comments
 (0)