android: Catch OutOfMemoryError when importing profiles

Not sure if this is actually caused because e.g. the file is too large
or due to some encoding issue.
This commit is contained in:
Tobias Brunner
2017-09-04 10:41:24 +02:00
parent 1a9261a923
commit ac3189f792
@@ -65,6 +65,7 @@ import java.io.ByteArrayOutputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.lang.OutOfMemoryError;
import java.net.URL; import java.net.URL;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.security.KeyStore; import java.security.KeyStore;
@@ -714,9 +715,16 @@ public class VpnProfileImportActivity extends AppCompatActivity
} }
} }
if (in != null) if (in != null)
{
try
{ {
result.Profile = streamToString(in); result.Profile = streamToString(in);
} }
catch (OutOfMemoryError e)
{ /* just use a generic exception */
result.ThrownException = new RuntimeException();
}
}
return result; return result;
} }