playgameservices / android-basic-samples

Google Play game services - Android samples
Apache License 2.0
971 stars 973 forks source link

Null pointer exception is possible if loading with conflicts #276

Open Guaranapps opened 6 years ago

Guaranapps commented 6 years ago

After reading your code (quite complex for just loading/saving games) a null pointer exception could be throws after confict: snapshot variable return by processOpenDataOrConflict (see https://github.com/playgameservices/android-basic-samples/blob/884881e9854c1e07cef51a4c1efa7dab42af1221/CollectAllTheStars2/src/main/java/com/google/example/games/catt2/MainActivity.java#L686) could be null and passed to SnapshotCoordinator.discardAndClose (see https://github.com/playgameservices/android-basic-samples/blob/884881e9854c1e07cef51a4c1efa7dab42af1221/CollectAllTheStars2/src/main/java/com/google/example/games/catt2/MainActivity.java#L699) which will throw NPE while trying to call getMetadata() (see https://github.com/playgameservices/android-basic-samples/blob/884881e9854c1e07cef51a4c1efa7dab42af1221/CollectAllTheStars2/src/main/java/com/google/example/games/catt2/SnapshotCoordinator.java#L222)