doc = xmlParseFile(path);
if (doc == NULL) {
+ SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to parse xml file");
return -1;
}
if (cur == NULL) {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] Empty document");
xmlFreeDoc(doc);
+ doc = NULL;
return -1;
}
if (xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_ENGINE_BASE_TAG)) {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] The wrong type, root node is NOT 'tts-engine'");
xmlFreeDoc(doc);
+ doc = NULL;
return -1;
}
if (cur == NULL) {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] Empty document");
xmlFreeDoc(doc);
+ doc = NULL;
return -1;
}
while (NULL != voice_node) {
if (0 == xmlStrcmp(voice_node->name, (const xmlChar *)TTS_TAG_ENGINE_VOICE)) {
-
tts_config_voice_s* temp_voice = (tts_config_voice_s*)calloc(1, sizeof(tts_config_voice_s));
if (NULL == temp_voice) {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] Out of memory");
xmlFree(attr);
} else {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] <%s> has no content", TTS_TAG_ENGINE_VOICE_TYPE);
+ free(temp_voice);
+ temp_voice = NULL;
+ continue;
}
key = xmlNodeGetContent(voice_node);
SLOG(LOG_ERROR, tts_tag(), "[ERROR] <%s> has no content", TTS_TAG_ENGINE_VOICE);
if (NULL != temp_voice) {
free(temp_voice);
+ temp_voice = NULL;
}
}
}
temp->pitch_support = true;
}
xmlFree(key);
+ key = NULL;
} else {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] <%s> has no content", TTS_TAG_ENGINE_PITCH_SUPPORT);
}
}
xmlFreeDoc(doc);
+ doc = NULL;
if (NULL == temp->name || NULL == temp->uuid) {
/* Invalid engine */
xmlChar *key;
bool is_default_open = false;
+ /* For Thread safety */
+ xmlInitParser();
+
if (0 != access(TTS_CONFIG, F_OK)) {
doc = xmlParseFile(TTS_DEFAULT_CONFIG);
if (doc == NULL) {
if (cur == NULL) {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] Empty document");
xmlFreeDoc(doc);
+ doc = NULL;
return -1;
}
if (xmlStrcmp(cur->name, (const xmlChar *) TTS_TAG_CONFIG_BASE_TAG)) {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] The wrong type, root node is NOT %s", TTS_TAG_CONFIG_BASE_TAG);
xmlFreeDoc(doc);
+ doc = NULL;
return -1;
}
if (cur == NULL) {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] Empty document");
xmlFreeDoc(doc);
+ doc = NULL;
return -1;
}
int tts_parser_unload_config(tts_config_s* config_info)
{
- if (NULL != g_config_doc) xmlFreeDoc(g_config_doc);
+ if (NULL != g_config_doc) {
+ xmlFreeDoc(g_config_doc);
+ g_config_doc = NULL;
+ }
if (NULL != config_info) {
- if (NULL != config_info->engine_id) free(config_info->engine_id);
- if (NULL != config_info->setting) free(config_info->setting);
- if (NULL != config_info->language) free(config_info->language);
+ if (NULL != config_info->engine_id) {
+ free(config_info->engine_id);
+ config_info->engine_id = NULL;
+ }
+ if (NULL != config_info->setting) {
+ free(config_info->setting);
+ config_info->setting = NULL;
+ }
+ if (NULL != config_info->language) {
+ free(config_info->language);
+ config_info->language = NULL;
+ }
free(config_info);
+ config_info = NULL;
}
return 0;
SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to change file mode : %d", ret);
}
- xmlFreeDoc(doc);
+ xmlFreeDoc(doc);
SLOG(LOG_DEBUG, tts_tag(), "[SUCCESS] Copying xml");
return 0;
if (cur_new == NULL || cur_old == NULL) {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] Empty document");
xmlFreeDoc(doc);
+ doc = NULL;
return -1;
}
xmlStrcmp(cur_old->name, (const xmlChar*)TTS_TAG_CONFIG_BASE_TAG)) {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] The wrong type, root node is NOT %s", TTS_TAG_CONFIG_BASE_TAG);
xmlFreeDoc(doc);
+ doc = NULL;
return -1;
}
if (cur_new == NULL || cur_old == NULL) {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] Empty document");
xmlFreeDoc(doc);
+ doc = NULL;
return -1;
}
cur_new = cur_new->next;
cur_old = cur_old->next;
}
-
- xmlFreeDoc(g_config_doc);
+
+ if (NULL != g_config_doc) {
+ xmlFreeDoc(g_config_doc);
+ g_config_doc = NULL;
+ }
g_config_doc = doc;
return 0;