[mod_java] Coverity CID 1320753 (Resource leak)
This commit is contained in:
parent
73ea37c5ab
commit
b02fbc702d
|
@ -300,8 +300,7 @@ static switch_status_t create_java_vm(JavaVMOption *options, int optionCount, vm
|
||||||
|
|
||||||
pJNI_CreateJavaVM = (jint (*)(JavaVM **, void **, void *))switch_dso_func_sym(javaVMHandle, "JNI_CreateJavaVM", &derr);
|
pJNI_CreateJavaVM = (jint (*)(JavaVM **, void **, void *))switch_dso_func_sym(javaVMHandle, "JNI_CreateJavaVM", &derr);
|
||||||
|
|
||||||
if (!derr)
|
if (!derr) {
|
||||||
{
|
|
||||||
JNIEnv *env;
|
JNIEnv *env;
|
||||||
JavaVMInitArgs initArgs;
|
JavaVMInitArgs initArgs;
|
||||||
jint res;
|
jint res;
|
||||||
|
@ -313,44 +312,38 @@ static switch_status_t create_java_vm(JavaVMOption *options, int optionCount, vm
|
||||||
initArgs.ignoreUnrecognized = JNI_TRUE;
|
initArgs.ignoreUnrecognized = JNI_TRUE;
|
||||||
|
|
||||||
res = pJNI_CreateJavaVM(&javaVM, (void*) &env, &initArgs);
|
res = pJNI_CreateJavaVM(&javaVM, (void*) &env, &initArgs);
|
||||||
if (res == JNI_OK)
|
if (res == JNI_OK) {
|
||||||
{
|
/* call FindClass here already so that the Java VM executes the static
|
||||||
// call FindClass here already so that the Java VM executes the static
|
initializer (@see org.freeswitch.Launcher) which loads the jni library
|
||||||
// initializer (@see org.freeswitch.Launcher) which loads the jni library
|
so we can use jni functions right away (for example in the startup method) */
|
||||||
// so we can use jni functions right away (for example in the startup method)
|
|
||||||
launcherClass = (*env)->FindClass(env, "org/freeswitch/Launcher");
|
launcherClass = (*env)->FindClass(env, "org/freeswitch/Launcher");
|
||||||
if ( launcherClass == NULL )
|
if ( launcherClass == NULL ) {
|
||||||
{
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to find 'org.freeswitch.Launcher' class!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to find 'org.freeswitch.Launcher' class!\n");
|
||||||
(*env)->ExceptionDescribe(env);
|
(*env)->ExceptionDescribe(env);
|
||||||
}
|
}
|
||||||
|
|
||||||
// store a global reference for use in the launch_java() function
|
/* store a global reference for use in the launch_java() function */
|
||||||
launcherClass = (*env)->NewGlobalRef(env, launcherClass);
|
launcherClass = (*env)->NewGlobalRef(env, launcherClass);
|
||||||
if ( launcherClass == NULL )
|
if ( launcherClass == NULL ) {
|
||||||
{
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Out of memory!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Out of memory!\n");
|
||||||
(*env)->ExceptionDescribe(env);
|
(*env)->ExceptionDescribe(env);
|
||||||
status = SWITCH_STATUS_FALSE;
|
status = SWITCH_STATUS_FALSE;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
status = SWITCH_STATUS_SUCCESS;
|
status = SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
(*javaVM)->DetachCurrentThread(javaVM);
|
(*javaVM)->DetachCurrentThread(javaVM);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error creating Java VM!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error creating Java VM!\n");
|
||||||
status = SWITCH_STATUS_FALSE;
|
status = SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Specified Java VM doesn't have JNI_CreateJavaVM\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Specified Java VM doesn't have JNI_CreateJavaVM\n");
|
||||||
|
switch_safe_free(derr);
|
||||||
status = SWITCH_STATUS_FALSE;
|
status = SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue