diff --git a/src/mod/languages/mod_java/modjava.c b/src/mod/languages/mod_java/modjava.c
index 899fee2b60..9c38bdb70f 100644
--- a/src/mod/languages/mod_java/modjava.c
+++ b/src/mod/languages/mod_java/modjava.c
@@ -189,107 +189,108 @@ SWITCH_STANDARD_APP(java_function)
static switch_status_t load_config(JavaVMOption **javaOptions, int *optionCount, vm_control_t * vmControl)
{
- switch_xml_t cfg, xml;
- switch_status_t status = SWITCH_STATUS_SUCCESS;
+ switch_xml_t cfg, xml;
+ switch_status_t status = SWITCH_STATUS_SUCCESS;
char *derr = NULL;
- xml = switch_xml_open_cfg("java.conf", &cfg, NULL);
- if (xml)
- {
- switch_xml_t javavm;
- switch_xml_t options;
- switch_xml_t startup;
- switch_xml_t shutdown;
+ xml = switch_xml_open_cfg("java.conf", &cfg, NULL);
+ if (xml) {
+ switch_xml_t javavm;
+ switch_xml_t options;
+ switch_xml_t startup;
+ switch_xml_t shutdown;
- javavm = switch_xml_child(cfg, "javavm");
- if (javavm != NULL)
- {
- const char *path = switch_xml_attr_soft(javavm, "path");
- if (path != NULL)
- {
+ javavm = switch_xml_child(cfg, "javavm");
+ if (javavm != NULL) {
+ const char *path = switch_xml_attr_soft(javavm, "path");
+
+ if (path != NULL) {
javaVMHandle = switch_dso_open(path, 0, &derr);
if (derr || !javaVMHandle) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error loading %s\n", path);
+ switch_safe_free(derr);
}
- }
- else
- {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Java VM path specified in java.conf.xml\n");
- status = SWITCH_STATUS_FALSE;
- }
- }
- else
- {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Java VM specified in java.conf.xml\n");
- status = SWITCH_STATUS_FALSE;
- goto close;
- }
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Java VM path specified in java.conf.xml\n");
+ status = SWITCH_STATUS_FALSE;
+ }
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Java VM specified in java.conf.xml\n");
+ status = SWITCH_STATUS_FALSE;
+ goto close;
+ }
+
+ options = switch_xml_child(cfg, "options");
+ if (options != NULL) {
+ switch_xml_t option;
+ int i = 0;
+
+ *optionCount = 0;
+
+ for (option = switch_xml_child(options, "option"); option; option = option->next) {
+ const char *value = switch_xml_attr_soft(option, "value");
+
+ if (value != NULL) {
+ ++*optionCount;
+ }
+ }
+
+ *optionCount += 1;
+ *javaOptions = switch_core_alloc(memoryPool, (switch_size_t)(*optionCount * sizeof(JavaVMOption)));
+ if (*javaOptions == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Out of memory!\n");
+ status = SWITCH_STATUS_FALSE;
+ goto close;
+ }
+
+ for (option = switch_xml_child(options, "option"); option; option = option->next) {
+ const char *value = switch_xml_attr_soft(option, "value");
+
+ if (value == NULL) {
+ continue;
+ }
+
+ (*javaOptions)[i].optionString = switch_core_strdup(memoryPool, value);
+ if ((*javaOptions)[i].optionString == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Out of memory!\n");
+ status = SWITCH_STATUS_FALSE;
+ goto close;
+ }
+
+ ++i;
+ }
- options = switch_xml_child(cfg, "options");
- if (options != NULL)
- {
- switch_xml_t option;
- int i = 0;
- *optionCount = 0;
- for (option = switch_xml_child(options, "option"); option; option = option->next)
- {
- const char *value = switch_xml_attr_soft(option, "value");
- if (value != NULL)
- ++*optionCount;
- }
- *optionCount += 1;
- *javaOptions = switch_core_alloc(memoryPool, (switch_size_t)(*optionCount * sizeof(JavaVMOption)));
- if (*javaOptions == NULL)
- {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Out of memory!\n");
- status = SWITCH_STATUS_FALSE;
- goto close;
- }
- for (option = switch_xml_child(options, "option"); option; option = option->next)
- {
- const char *value = switch_xml_attr_soft(option, "value");
- if (value == NULL)
- continue;
- (*javaOptions)[i].optionString = switch_core_strdup(memoryPool, value);
- if ((*javaOptions)[i].optionString == NULL)
- {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Out of memory!\n");
- status = SWITCH_STATUS_FALSE;
- goto close;
- }
- ++i;
- }
(*javaOptions)[i].optionString = switch_core_sprintf(memoryPool, "-Djava.library.path=%s", SWITCH_GLOBAL_dirs.mod_dir);
- }
+ }
- /*
-
-
- */
+ /*
+
+
+ */
- memset(vmControl, 0, sizeof(struct vm_control));
- startup = switch_xml_child(cfg, "startup");
- if (startup != NULL) {
- vmControl->startup.class = switch_xml_attr_soft(startup, "class");
- vmControl->startup.method = switch_xml_attr_soft(startup, "method");
- vmControl->startup.arg = switch_xml_attr_soft(startup, "arg");
- }
- shutdown = switch_xml_child(cfg, "shutdown");
- if (shutdown != NULL) {
- vmControl->shutdown.class = switch_xml_attr_soft(shutdown, "class");
- vmControl->shutdown.method = switch_xml_attr_soft(shutdown, "method");
- vmControl->shutdown.arg = switch_xml_attr_soft(shutdown, "arg");
- }
+ memset(vmControl, 0, sizeof(struct vm_control));
+ startup = switch_xml_child(cfg, "startup");
+ if (startup != NULL) {
+ vmControl->startup.class = switch_xml_attr_soft(startup, "class");
+ vmControl->startup.method = switch_xml_attr_soft(startup, "method");
+ vmControl->startup.arg = switch_xml_attr_soft(startup, "arg");
+ }
- close:
- switch_xml_free(xml);
- }
- else
- {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening java.conf.xml\n");
- status = SWITCH_STATUS_FALSE;
- }
- return status;
+ shutdown = switch_xml_child(cfg, "shutdown");
+ if (shutdown != NULL) {
+ vmControl->shutdown.class = switch_xml_attr_soft(shutdown, "class");
+ vmControl->shutdown.method = switch_xml_attr_soft(shutdown, "method");
+ vmControl->shutdown.arg = switch_xml_attr_soft(shutdown, "arg");
+ }
+
+ close:
+ switch_xml_free(xml);
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening java.conf.xml\n");
+ status = SWITCH_STATUS_FALSE;
+ }
+
+ return status;
}
static switch_status_t create_java_vm(JavaVMOption *options, int optionCount, vm_control_t * vmControl)