From 8d160869692a8372cff3f1c0893935a559e5b55a Mon Sep 17 00:00:00 2001 From: Martin Fleisz Date: Tue, 2 Apr 2013 06:33:59 -0700 Subject: [PATCH] Android: Fix crash after changes in FreeRDP directory handling --- client/Android/FreeRDPCore/jni/android_freerdp.c | 6 +++++- winpr/libwinpr/path/shell.c | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/client/Android/FreeRDPCore/jni/android_freerdp.c b/client/Android/FreeRDPCore/jni/android_freerdp.c index 2bcb1f334..1e8b7772c 100644 --- a/client/Android/FreeRDPCore/jni/android_freerdp.c +++ b/client/Android/FreeRDPCore/jni/android_freerdp.c @@ -536,8 +536,12 @@ JNIEXPORT void JNICALL jni_freerdp_set_data_directory(JNIEnv *env, jclass cls, j free(settings->HomePath); free(settings->ConfigPath); + int config_dir_len = strlen(directory) + 10; /* +9 chars for /.freerdp and +1 for \0 */ + char* config_dir_buf = (char*)malloc(config_dir_len); + strcpy(config_dir_buf, directory); + strcat(config_dir_buf, "/.freerdp"); settings->HomePath = strdup(directory); - settings->ConfigPath = NULL; + settings->ConfigPath = config_dir_buf; /* will be freed by freerdp library */ (*env)->ReleaseStringUTFChars(env, jdirectory, directory); } diff --git a/winpr/libwinpr/path/shell.c b/winpr/libwinpr/path/shell.c index 9d111debd..c60baa7ac 100644 --- a/winpr/libwinpr/path/shell.c +++ b/winpr/libwinpr/path/shell.c @@ -66,6 +66,9 @@ char* GetPath_HOME() #ifdef _WIN32 path = GetEnvAlloc("UserProfile"); +#elif defined(ANDROID) + path = malloc(2); + strcpy(path, "/"); #else path = GetEnvAlloc("HOME"); #endif