Skip to contentSkip to conversation

qcow2: free old snapshots array upon creation of a new one

PATCH Applied Uri Lublin 2 participants 2 messages Jan 8, 2009

lore
Share & tools
lore

Uri Lublin

author
#0 lore raw

PATCH v2 1/1 qcow2: free old snapshots array upon creation of a new one

From: Uri Lublin <[email protected]>

Don't leak memory

Rebased for qemu tree.

---
 block-qcow2.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
block-qcow2.c +1 -0
index 707109e..9aa7261 100644
@@ -2024,6 +2024,7 @@ static int qcow_snapshot_create(BlockDriverState *bs,
     if (!snapshots1)
         goto fail;
     memcpy(snapshots1, s->snapshots, s->nb_snapshots * sizeof(QCowSnapshot));
+    qemu_free(s->snapshots);
     s->snapshots = snapshots1;
     s->snapshots[s->nb_snapshots++] = *sn;
 
Signature · 1 line
1.6.0.6
#1 lore raw
Quoted 7 lines · Uri Lublin

From: Uri Lublin <[email protected]>

Don't leak memory

Rebased for qemu tree.

Applied. Well, sort of. It appears to be whitespace damaged and didn't apply. It was simple enough that I just made the change manually though.

Regards,

Anthony Liguori

Quoted 18 lines
---
 block-qcow2.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
block-qcow2.c +1 -0
index 707109e..9aa7261 100644
@@ -2024,6 +2024,7 @@ static int qcow_snapshot_create(BlockDriverState 
 *bs,
     if (!snapshots1)
         goto fail;
     memcpy(snapshots1, s->snapshots, s->nb_snapshots * 
 sizeof(QCowSnapshot));
+    qemu_free(s->snapshots);
     s->snapshots = snapshots1;
     s->snapshots[s->nb_snapshots++] = *sn;