block: replace unchecked strdup/malloc/calloc with glib
PATCH 1/1 block: replace unchecked strdup/malloc/calloc with glib
Most of the codebase as been converted to use glib memory allocation functions. There are still a few instances of malloc/calloc in the block layer and qemu-io. Replace them, especially since they do not check the strdup/malloc/calloc return value.
Reported-by Dr David Alan Gilbert <[email protected]>
Signed-off-by Stefan Hajnoczi <[email protected]>
--- block/blkdebug.c | 4 ++-- block/blkverify.c | 4 ++-- qemu-io.c | 48 ++++++++++++++++++++++++------------------------ 3 files changed, 28 insertions(+), 28 deletions(-)
block/blkdebug.c +2 -2
@@ -292,10 +292,10 @@ static int blkdebug_open(BlockDriverState *bs, const char *filename, int flags)return -EINVAL ; } - config =strdup (filename); + config =g_strdup (filename); config[c - filename] ='\0' ; ret =read_config (s, config); -free (config); +g_free (config);if (ret <0 ) {return ret; }
block/blkverify.c +2 -2
@@ -87,10 +87,10 @@ static int blkverify_open(BlockDriverState *bs, const char *filename, int flags)return -EINVAL ; } - raw =strdup (filename); + raw =g_strdup (filename); raw[c - filename] ='\0' ; ret =bdrv_file_open (&bs->file, raw, flags); -free (raw); +g_free (raw);if (ret <0 ) {return ret; }
qemu-io.c +24 -24
187 lines not on this page · raw message
Signature · 1 line
1.7.8.3
Kevin Wolf
AppliedAm 16.01.2012 10:28, schrieb Stefan Hajnoczi:
Quoted 7 lines
Most of the codebase as been converted to use glib memory allocation functions. There are still a few instances of malloc/calloc in the block layer and qemu-io. Replace them, especially since they do not check the strdup/malloc/calloc return value.
Reported-by Dr David Alan Gilbert <[email protected]>Signed-off-by Stefan Hajnoczi <[email protected]>
Thanks, applied to the block branch.
Kevin