From d4e899b6be94e3a917185e7fe123884bda7f6495 Mon Sep 17 00:00:00 2001 From: Peter Osterlund Date: Mon, 28 Sep 2020 19:27:13 +0200 Subject: [PATCH] Avoid NPE if opening a shared input stream fails --- DroidFishApp/src/main/java/org/petero/droidfish/DroidFish.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/DroidFishApp/src/main/java/org/petero/droidfish/DroidFish.java b/DroidFishApp/src/main/java/org/petero/droidfish/DroidFish.java index 45c6018..1697319 100644 --- a/DroidFishApp/src/main/java/org/petero/droidfish/DroidFish.java +++ b/DroidFishApp/src/main/java/org/petero/droidfish/DroidFish.java @@ -795,6 +795,8 @@ public class DroidFish extends Activity String fn = Environment.getExternalStorageDirectory() + sep + pgnDir + sep + ".sharedfile.pgn"; try (InputStream in = resolver.openInputStream(data)) { + if (in == null) + throw new IOException("No input stream"); FileUtil.writeFile(in, fn); } PGNFile pgnFile = new PGNFile(fn);