summaryrefslogtreecommitdiff
path: root/desktop/source/lib/lokandroid.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'desktop/source/lib/lokandroid.cxx')
-rw-r--r--desktop/source/lib/lokandroid.cxx16
1 files changed, 10 insertions, 6 deletions
diff --git a/desktop/source/lib/lokandroid.cxx b/desktop/source/lib/lokandroid.cxx
index 15c41c444cb1..a6f02d6f74f3 100644
--- a/desktop/source/lib/lokandroid.cxx
+++ b/desktop/source/lib/lokandroid.cxx
@@ -190,16 +190,20 @@ extern "C" SAL_JNI_EXPORT jint JNICALL Java_org_libreoffice_kit_Office_saveAs
/* DirectBufferAllocator */
extern "C" SAL_JNI_EXPORT jobject JNICALL Java_org_libreoffice_kit_DirectBufferAllocator_allocateDirectBufferNative
- (JNIEnv* pEnv, jclass /*aClass*/, jlong nSize)
+ (JNIEnv* pEnv, jclass /*aClass*/, jint nSize)
{
jobject aBuffer = NULL;
- void* pMemory = malloc(nSize);
- if (pMemory != NULL)
+
+ if (nSize > 0)
{
- aBuffer = pEnv->NewDirectByteBuffer(pMemory, nSize);
- if (!aBuffer)
+ void* pMemory = malloc(nSize);
+ if (pMemory != NULL)
{
- free(pMemory);
+ aBuffer = pEnv->NewDirectByteBuffer(pMemory, nSize);
+ if (aBuffer == NULL)
+ {
+ free(pMemory);
+ }
}
}
return aBuffer;