Commit eb0b64f7aa7f6f325aac878265ee9e6c2fc1bf51

Authored by malc
1 parent 0a656f5f

Do not attempt to allocate sn_tab when there are no snapshots

This was caught by a7d27b53 which
aborted on this attempt, thanks to Alex Ivanov for report.

Signed-off-by: malc <av1474@comtv.ru>
Showing 1 changed file with 5 additions and 0 deletions
block/qcow2.c
... ... @@ -2259,6 +2259,11 @@ static int qcow_snapshot_list(BlockDriverState *bs,
2259 2259 QCowSnapshot *sn;
2260 2260 int i;
2261 2261  
  2262 + if (!s->nb_snapshots) {
  2263 + *psn_tab = NULL;
  2264 + return s->nb_snapshots;
  2265 + }
  2266 +
2262 2267 sn_tab = qemu_mallocz(s->nb_snapshots * sizeof(QEMUSnapshotInfo));
2263 2268 for(i = 0; i < s->nb_snapshots; i++) {
2264 2269 sn_info = sn_tab + i;
... ...