Skip to content

Commit

Permalink
fix(auth, android): use a safe copy of auth provider info to avoid crash
Browse files Browse the repository at this point in the history
The auth provider data may apparently be modified while being iterated to send to
listeners, resulting in a classic ConcurrentModificationException crash

Using a shallow copy of the collection for iteration should be a functional equivalent,
but without the unwanted "feature" of crashing

Fixes #6798
  • Loading branch information
mikehardy committed Jan 21, 2023
1 parent 8600ead commit 24b4d5d
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
import io.invertase.firebase.common.ReactNativeFirebaseModule;
import io.invertase.firebase.common.SharedUtils;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
Expand Down Expand Up @@ -2055,7 +2056,8 @@ private WritableMap getJSError(Exception exception) {
private WritableArray convertProviderData(
List<? extends UserInfo> providerData, FirebaseUser user) {
WritableArray output = Arguments.createArray();
for (UserInfo userInfo : providerData) {
ArrayList<? extends UserInfo> providerDataCopy = new ArrayList(providerData);
for (UserInfo userInfo : providerDataCopy) {
// remove 'firebase' provider data - android fb sdk
// should not be returning this as the ios/web ones don't
if (!FirebaseAuthProvider.PROVIDER_ID.equals(userInfo.getProviderId())) {
Expand Down

0 comments on commit 24b4d5d

Please sign in to comment.