summaryrefslogtreecommitdiff
path: root/android/Bootstrap
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2015-01-15 15:33:58 +0900
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-01-16 13:18:31 +0100
commita5e2c361f031e1ce55c4110145a0d1011eba11b3 (patch)
treeaf387607907891d7c8d51bba278333ede09f08bb /android/Bootstrap
parent1e4f6eeba42f68d2587700e45ba1362f920174a3 (diff)
android: guard buffer allocation and return null if alloc. fails
Change-Id: I684c7af245cc755b94f69e175c652d161e0f643a
Diffstat (limited to 'android/Bootstrap')
-rw-r--r--android/Bootstrap/src/org/libreoffice/kit/DirectBufferAllocator.java10
1 files changed, 10 insertions, 0 deletions
diff --git a/android/Bootstrap/src/org/libreoffice/kit/DirectBufferAllocator.java b/android/Bootstrap/src/org/libreoffice/kit/DirectBufferAllocator.java
index 0e30e459ff93..670e39724aad 100644
--- a/android/Bootstrap/src/org/libreoffice/kit/DirectBufferAllocator.java
+++ b/android/Bootstrap/src/org/libreoffice/kit/DirectBufferAllocator.java
@@ -87,4 +87,14 @@ public final class DirectBufferAllocator {
// can't free buffer - leave this to the VM
return null;
}
+
+ public static ByteBuffer guardedAllocate(int size) {
+ ByteBuffer buffer = null;
+ try {
+ buffer = allocate(size);
+ } catch (OutOfMemoryError oomException) {
+ return null;
+ }
+ return buffer;
+ }
}