diff --git a/src/native/linux/linux_al.c b/src/native/linux/linux_al.c index d0d412f7..b114af09 100644 --- a/src/native/linux/linux_al.c +++ b/src/native/linux/linux_al.c @@ -48,13 +48,13 @@ void *NativeGetFunctionPointer(const char *function) { void tryLoadLibrary(JNIEnv *env, jstring path) { char *path_str = GetStringNativeChars(env, path); printfDebugJava(env, "Testing '%s'", path_str); - free(path_str); handleOAL = dlopen(path_str, RTLD_LAZY); if (handleOAL != NULL) { printfDebugJava(env, "Found OpenAL at '%s'", path_str); } else { throwException(env, "Could not load OpenAL library"); } + free(path_str); } void UnLoadOpenAL() { diff --git a/src/native/macosx/macosx_al.c b/src/native/macosx/macosx_al.c index 316d9464..11f11a72 100644 --- a/src/native/macosx/macosx_al.c +++ b/src/native/macosx/macosx_al.c @@ -93,12 +93,12 @@ void tryLoadLibrary(JNIEnv *env, jstring path) { const char *path_str = (*env)->GetStringUTFChars(env, path, NULL); printfDebugJava(env, "Testing '%s'", path_str); handleOAL = NSAddImage(path_str, NSADDIMAGE_OPTION_RETURN_ON_ERROR); - (*env)->ReleaseStringUTFChars(env, path, path_str); if (handleOAL != NULL) { printfDebugJava(env, "Found OpenAL at '%s'", path_str); } else { throwException(env, "Could not load OpenAL library"); } + (*env)->ReleaseStringUTFChars(env, path, path_str); } /** diff --git a/src/native/windows/windows_al.c b/src/native/windows/windows_al.c index c5ea58dc..8cf0ffad 100644 --- a/src/native/windows/windows_al.c +++ b/src/native/windows/windows_al.c @@ -55,12 +55,12 @@ void tryLoadLibrary(JNIEnv *env, jstring path) { char *path_str = GetStringNativeChars(env, path); printfDebugJava(env, "Testing '%s'", path_str); handleOAL = LoadLibrary(path_str); - free(path_str); if (handleOAL != NULL) { printfDebugJava(env, "Found OpenAL at '%s'", path_str); } else { throwException(env, "Could not load OpenAL library (%d)", GetLastError()); } + free(path_str); } /**