提交 a0e5faaf 编写于 作者: M Michal Privoznik

vbox: Avoid signed and unsigned comparison

After 457ff97f there are two defects in our code. In both of
them we use a signed variable to hold up a number of snapshots
that domain has. We use a helper function to count the number.
However, the helper function may fail in which case it returns
a negative one and control jumps to cleanup label where an
unsigned variable is used to iterate over array of snapshots. The
loop condition thus compare signed and unsigned variables which
in this specific case ends up badly for us.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
上级 0f396a41
......@@ -5507,11 +5507,10 @@ vboxDomainSnapshotGet(vboxGlobalData *data,
ISnapshot **snapshots = NULL;
ISnapshot *snapshot = NULL;
nsresult rc;
int count = 0;
size_t i;
ssize_t i, count = 0;
if ((count = vboxDomainSnapshotGetAll(dom, machine, &snapshots)) < 0)
goto cleanup;
return NULL;
for (i = 0; i < count; i++) {
PRUnichar *nameUtf16;
......@@ -6188,8 +6187,7 @@ static int vboxDomainSnapshotListNames(virDomainPtr dom, char **names,
IMachine *machine = NULL;
nsresult rc;
ISnapshot **snapshots = NULL;
int count = 0;
size_t i;
ssize_t i, count = 0;
int ret = -1;
if (!data->vboxObj)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册