]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
android: Catch OutOfMemoryError when importing profiles
authorTobias Brunner <tobias@strongswan.org>
Mon, 10 Jul 2017 10:17:45 +0000 (12:17 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 4 Sep 2017 08:41:24 +0000 (10:41 +0200)
Not sure if this is actually caused because e.g. the file is too large
or due to some encoding issue.

src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnProfileImportActivity.java

index 5cfcf48954e4abec8435e352522155d69253a002..cee95c36ff5332872fde8a834d833e6f95f693ea 100644 (file)
@@ -65,6 +65,7 @@ import java.io.ByteArrayOutputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
+import java.lang.OutOfMemoryError;
 import java.net.URL;
 import java.net.UnknownHostException;
 import java.security.KeyStore;
@@ -715,7 +716,14 @@ public class VpnProfileImportActivity extends AppCompatActivity
                        }
                        if (in != null)
                        {
-                               result.Profile = streamToString(in);
+                               try
+                               {
+                                       result.Profile = streamToString(in);
+                               }
+                               catch (OutOfMemoryError e)
+                               {       /* just use a generic exception */
+                                       result.ThrownException = new RuntimeException();
+                               }
                        }
                        return result;
                }