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.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;
}