提交 bb22de2e 编写于 作者: P Pavel Hrdina

Fix possible memory leak in virsh-domain-monitor.c in cmdDomblklist

In a "for" loop there are created two new strings and they may not
be freed if a "target" string cannot be obtained. We have to free
the two created strings to prevent the memory leak.

This has been found by coverity.

John also pointed out that we should somehow care about the "type"
and "device" and Osier agreed to exit with error message if one of
them is set to NULL.
Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
上级 362da820
......@@ -545,8 +545,8 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd)
vshPrint(ctl, "------------------------------------------------\n");
for (i = 0; i < ndisks; i++) {
char *type;
char *device;
char *type = NULL;
char *device = NULL;
char *target;
char *source;
......@@ -555,11 +555,19 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd)
if (details) {
type = virXPathString("string(./@type)", ctxt);
device = virXPathString("string(./@device)", ctxt);
if (!type || !device) {
vshPrint(ctl, "unable to query block list details");
VIR_FREE(type);
VIR_FREE(device);
goto cleanup;
}
}
target = virXPathString("string(./target/@dev)", ctxt);
if (!target) {
vshError(ctl, "unable to query block list");
VIR_FREE(type);
VIR_FREE(device);
goto cleanup;
}
source = virXPathString("string(./source/@file"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册