]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: snapshot: check return value of virDomainSnapshotObjListNum
authorJán Tomko <jtomko@redhat.com>
Wed, 28 Nov 2012 13:34:51 +0000 (14:34 +0100)
committerOsier Yang <jyang@redhat.com>
Wed, 28 Nov 2012 16:00:39 +0000 (00:00 +0800)
If it's negative, this might result in a request to allocate lots of
memory.

src/conf/snapshot_conf.c

index 72bdd3022170c022a880e862b11a94e5e97de04f..06be34d9263a6e7f03ed0afb2cb56b51e74af993 100644 (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) {