block: Fix memory leak in bdrv_next()
PATCH 1/1 block: Fix memory leak in bdrv_next()
When all BDSes have already been iterated and we return NULL, the iterator must be freed, too.
Signed-off-by Kevin Wolf <[email protected]>
--- block/block-backend.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
block/block-backend.c +6 -1
@@ -329,7 +329,12 @@ BdrvNextIterator *bdrv_next(BdrvNextIterator *it, BlockDriverState **bs) *bs = it->bs; }while (*bs &&bdrv_has_blk (*bs)); -return *bs ? it :NULL ; +if (*bs) { +return it; + }else { +g_free (it); +return NULL ; + } }/*
Signature · 1 line
1.8.3.1
Kevin Wolf
NAKAm 20.05.2016 um 09:57 hat Kevin Wolf geschrieben:
Quoted 4 lines
When all BDSes have already been iterated and we return NULL, the iterator must be freed, too.
Signed-off-by Kevin Wolf <[email protected]>
NACK, this doesn't fix cases where the caller exists loop prematurely.
Kevin