conf: snapshot: check return value of virDomainSnapshotObjListNum

If it's negative, this might result in a request to allocate lots of
memory.
This commit is contained in:
Ján Tomko 2012-11-28 14:34:51 +01:00 committed by Osier Yang
parent 34e5791332
commit 0361917619

View File

@ -1026,7 +1026,7 @@ virDomainListSnapshots(virDomainSnapshotObjListPtr snapshots,
int ret = -1;
int i;
if (!snaps)
if (!snaps || count < 0)
return count;
if (VIR_ALLOC_N(names, count) < 0 ||
VIR_ALLOC_N(list, count + 1) < 0) {