提交 3b1a5dde 编写于 作者: M Michal Privoznik

test_driver: Don't access @vm after it was set to NULL

If something goes wrong in testDomainGetDiskErrors() then we try
to free any strings that were previously allocated in return
array. Problem is, in my review of original patch (89320788)
I've mistakenly did some changes which result in possible NULL
dereference (@vm is set to NULL as the first thing under cleanup
label).
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: NAndrea Bolognani <abologna@redhat.com>
上级 50dfabbb
......@@ -3268,7 +3268,7 @@ static int testDomainGetDiskErrors(virDomainPtr dom,
virCheckFlags(0, -1);
if (!(vm = testDomObjFromDomain(dom)))
goto cleanup;
return -1;
if (virDomainObjCheckActive(vm) < 0)
goto cleanup;
......@@ -3285,11 +3285,11 @@ static int testDomainGetDiskErrors(virDomainPtr dom,
}
cleanup:
virDomainObjEndAPI(&vm);
if (ret < 0) {
for (i = 0; i < MIN(vm->def->ndisks, maxerrors); i++)
VIR_FREE(errors[i].disk);
}
virDomainObjEndAPI(&vm);
return ret;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册