summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorChristian Lohmaier <lohmaier+LibreOffice@googlemail.com>2018-04-07 21:01:10 +0200
committerChristian Lohmaier <lohmaier+LibreOffice@googlemail.com>2018-04-07 22:17:08 +0200
commit59f88e62f53cf54f441f51456767f6ba0e52ca54 (patch)
treecc353543a71f50bddfe351de5e4900f367868b35 /android
parente3104eb246bdf623ad01fee8ba192a4926cb264c (diff)
prevent crash on invalid bitmap size
sometimes the width and height cannot be determined properly (and 0 in that case), and this causes IllegalArgumentException when trying to create the Bitmap Change-Id: Id001c40d0febf9e85b4db5c0318a77e1f880353a
Diffstat (limited to 'android')
-rw-r--r--android/source/src/java/org/libreoffice/LOKitTileProvider.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/android/source/src/java/org/libreoffice/LOKitTileProvider.java b/android/source/src/java/org/libreoffice/LOKitTileProvider.java
index a96f6092363c..bf2c2601e7cd 100644
--- a/android/source/src/java/org/libreoffice/LOKitTileProvider.java
+++ b/android/source/src/java/org/libreoffice/LOKitTileProvider.java
@@ -467,8 +467,13 @@ class LOKitTileProvider implements TileProvider {
if (mDocument != null)
mDocument.paintTile(buffer, widthPixel, heightPixel, 0, 0, (int) mWidthTwip, (int) mHeightTwip);
- Bitmap bitmap = Bitmap.createBitmap(widthPixel, heightPixel, Bitmap.Config.ARGB_8888);
- bitmap.copyPixelsFromBuffer(buffer);
+ Bitmap bitmap = null;
+ try {
+ bitmap = Bitmap.createBitmap(widthPixel, heightPixel, Bitmap.Config.ARGB_8888);
+ bitmap.copyPixelsFromBuffer(buffer);
+ } catch (IllegalArgumentException e) {
+ Log.e(LOGTAG, "width (" + widthPixel + ") and height (" + heightPixel + ") must not be 0! (ToDo: likely timing issue)");
+ }
if (bitmap == null) {
Log.w(LOGTAG, "Thumbnail not created!");
}