summaryrefslogtreecommitdiff
path: root/sal/android/libreofficekit-jni.c
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2014-10-15 10:17:15 +0300
committerToma┼ż Vajngerl <tomaz.vajngerl@collabora.com>2014-12-04 23:04:21 +0100
commit66974e684643092f2419835705188c6410e0e7db (patch)
treee2c5e451bb469fc7d509f2ac1ca4990fa59d33e7 /sal/android/libreofficekit-jni.c
parent13e6637e1f2891179b6ed9fc53292623aadb7728 (diff)
Don't keep the LibreOfficeKit pointer in a global variable
It is invalid in case lo_destroy() has been called. Change-Id: I45533b66d32fc650e48748da8ea1d2f2aaa381e0
Diffstat (limited to 'sal/android/libreofficekit-jni.c')
-rw-r--r--sal/android/libreofficekit-jni.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/sal/android/libreofficekit-jni.c b/sal/android/libreofficekit-jni.c
index 12bb3f99b26c..416198234051 100644
--- a/sal/android/libreofficekit-jni.c
+++ b/sal/android/libreofficekit-jni.c
@@ -40,7 +40,7 @@ extern void Java_org_libreoffice_android_Bootstrap_redirect_1stdio(JNIEnv* env,
extern LibreOfficeKit* libreofficekit_hook(const char* install_path);
-static LibreOfficeKit* gpOffice;
+static char *full_program_dir = NULL;
/// Call the same method from Bootstrap.
__attribute__ ((visibility("default")))
@@ -73,7 +73,6 @@ jboolean Java_org_libreoffice_kit_LibreOfficeKit_initializeNative
const char program_dir[] = "/program";
size_t data_dir_len;
- char *full_program_dir;
(void) clazz;
@@ -128,6 +127,7 @@ jboolean Java_org_libreoffice_kit_LibreOfficeKit_initializeNative
extract_files(UNPACK_TREE_GZ, UNPACK_TREE_GZ, 1);
// LibreOfficeKit expects a path to the program/ directory
+ free(full_program_dir);
data_dir_len = strlen(data_dir);
full_program_dir = malloc(data_dir_len + sizeof(program_dir));
@@ -135,10 +135,7 @@ jboolean Java_org_libreoffice_kit_LibreOfficeKit_initializeNative
strncpy(full_program_dir + data_dir_len, program_dir, sizeof(program_dir));
// Initialize LibreOfficeKit
- gpOffice = libreofficekit_hook(full_program_dir);
-
- free(full_program_dir);
- if (!gpOffice)
+ if (!libreofficekit_hook(full_program_dir))
{
LOGE("libreofficekit_hook returned null");
return JNI_FALSE;
@@ -156,7 +153,7 @@ jlong Java_org_libreoffice_kit_LibreOfficeKit_getLibreOfficeKitHandle
(void) env;
(void) clazz;
- return (jlong) (intptr_t) gpOffice;
+ return (jlong) (intptr_t) libreofficekit_hook(full_program_dir);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */