diff options
author | malc <av1474@comtv.ru> | 2009-05-21 05:40:23 +0400 |
---|---|---|
committer | malc <av1474@comtv.ru> | 2009-05-21 05:40:53 +0400 |
commit | eb0b64f7aa7f6f325aac878265ee9e6c2fc1bf51 (patch) | |
tree | 0b4ecb18462560a15f405d79546211900f8aba6f | |
parent | 0a656f5f21553b9b69392d89e28d18361a0e3405 (diff) | |
download | hqemu-eb0b64f7aa7f6f325aac878265ee9e6c2fc1bf51.zip hqemu-eb0b64f7aa7f6f325aac878265ee9e6c2fc1bf51.tar.gz |
Do not attempt to allocate sn_tab when there are no snapshots
This was caught by a7d27b536ffc0773028a90f14580552c0c3ddb2a which
aborted on this attempt, thanks to Alex Ivanov for report.
Signed-off-by: malc <av1474@comtv.ru>
-rw-r--r-- | block/qcow2.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/block/qcow2.c b/block/qcow2.c index a6de9b6..33f3299 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2259,6 +2259,11 @@ static int qcow_snapshot_list(BlockDriverState *bs, QCowSnapshot *sn; int i; + if (!s->nb_snapshots) { + *psn_tab = NULL; + return s->nb_snapshots; + } + sn_tab = qemu_mallocz(s->nb_snapshots * sizeof(QEMUSnapshotInfo)); for(i = 0; i < s->nb_snapshots; i++) { sn_info = sn_tab + i; |