Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix: fixed a memory leak in stonithd and crmd.

  • Loading branch information...
commit 8184e4243de1db80ecae50c2f9d1ac0ed4d5aefb 1 parent 0df3829
@yuusuke yuusuke authored
View
2  crmd/te_callbacks.c
@@ -178,6 +178,8 @@ te_update_diff(const char *event, xmlNode * msg)
}
}
+ xmlXPathFreeObject(xpathObj);
+
} else if (xpathObj) {
xmlXPathFreeObject(xpathObj);
}
View
14 fencing/commands.c
@@ -526,9 +526,16 @@ is_nodeid_required(xmlNode * xml)
}
xpath = xpath_search(xml, "//parameter[@name='nodeid']");
if (!xpath || xpath->nodesetval->nodeNr <= 0) {
+ if (xpath) {
+ xmlXPathFreeObject(xpath);
+ }
return FALSE;
}
+ if (xpath) {
+ xmlXPathFreeObject(xpath);
+ }
+
return TRUE;
}
@@ -547,6 +554,9 @@ get_on_target_actions(xmlNode * xml)
xpath = xpath_search(xml, "//action");
if (!xpath || !xpath->nodesetval) {
+ if (xpath) {
+ xmlXPathFreeObject(xpath);
+ }
return NULL;
}
@@ -572,6 +582,10 @@ get_on_target_actions(xmlNode * xml)
}
}
+ if (xpath) {
+ xmlXPathFreeObject(xpath);
+ }
+
if (!strlen(actions)) {
free(actions);
actions = NULL;
View
12 fencing/main.c
@@ -535,6 +535,10 @@ static bool filter_cib_device(const char *rsc_id, xmlNode *device)
return TRUE;
}
+ if (rules) {
+ xmlXPathFreeObject(rules);
+ }
+
rule_path = g_strdup_printf("//" XML_CONS_TAG_RSC_LOCATION "[@rsc='%s']//"XML_TAG_RULE"[@"XML_RULE_ATTR_SCORE"='-INFINITY']//"XML_TAG_EXPRESSION, rsc_id);
crm_trace("Testing rule-based constraint: %s", rule_path);
rules = xpath_search(local_cib, rule_path);
@@ -567,6 +571,11 @@ static bool filter_cib_device(const char *rsc_id, xmlNode *device)
return TRUE;
}
}
+
+ if (rules) {
+ xmlXPathFreeObject(rules);
+ }
+
crm_trace("All done");
return FALSE;
}
@@ -605,6 +614,8 @@ update_cib_device(xmlNode *device, gboolean force)
data = create_device_registration_xml(rsc_id, provider, agent, params);
stonith_device_register(data, NULL, TRUE);
+ free_xml(data);
+ stonith_key_value_freeall(params, 1, 1);
}
}
@@ -625,6 +636,7 @@ register_cib_devices(xmlXPathObjectPtr xpathObj, gboolean force)
if (strcmp("stonith", standard) == 0) {
char *device_path = g_strdup_printf("//%s[@id='%s']", XML_CIB_TAG_RESOURCE, rsc_id);
xmlNode *device = get_xpath_object(device_path, local_cib, LOG_ERR);
+ free(device_path);
update_cib_device(device, force);
}
}
View
13 lib/fencing/st_client.c
@@ -1081,6 +1081,10 @@ stonith_api_device_metadata(stonith_t * stonith, int call_options, const char *a
actions = getXpathResult(xpathObj, 0);
}
+ if (xpathObj) {
+ xmlXPathFreeObject(xpathObj);
+ }
+
/* Now fudge the metadata so that the start/stop actions appear */
xpathObj = xpath_search(xml, "//action[@name='stop']");
if (xpathObj == NULL || xpathObj->nodesetval->nodeNr <= 0) {
@@ -1095,6 +1099,10 @@ stonith_api_device_metadata(stonith_t * stonith, int call_options, const char *a
crm_xml_add(tmp, "timeout", "20s");
}
+ if (xpathObj) {
+ xmlXPathFreeObject(xpathObj);
+ }
+
/* Now fudge the metadata so that the port isn't required in the configuration */
xpathObj = xpath_search(xml, "//parameter[@name='port']");
if (xpathObj && xpathObj->nodesetval->nodeNr > 0) {
@@ -1104,6 +1112,9 @@ stonith_api_device_metadata(stonith_t * stonith, int call_options, const char *a
crm_xml_add(tmp, "required", "0");
}
+ if (xpathObj) {
+ xmlXPathFreeObject(xpathObj);
+ }
free(buffer);
buffer = dump_xml_formatted(xml);
free_xml(xml);
@@ -1242,6 +1253,8 @@ stonith_api_query(stonith_t * stonith, int call_options, const char *target,
crm_info("%s[%d] = %s", "//@agent", lpc, xmlGetNodePath(match));
*devices = stonith_key_value_add(*devices, NULL, crm_element_value(match, XML_ATTR_ID));
}
+
+ xmlXPathFreeObject(xpathObj);
}
free_xml(output);
Please sign in to comment.
Something went wrong with that request. Please try again.