summaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@linux.vnet.ibm.com>2012-01-16 09:28:06 +0000
committerKevin Wolf <kwolf@redhat.com>2012-01-26 11:39:03 +0100
commit031380d8770d2df6c386e4aeabd412007d3ebd54 (patch)
tree400e4b4debd8540eb2d6558e38d13e2cb6783dc5 /block
parentbd6032470631d8d5de6db84ecb55398b70d9d2f3 (diff)
downloadqemu-031380d8770d2df6c386e4aeabd412007d3ebd54.tar.gz
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 <davidagilbert@uk.ibm.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/blkdebug.c4
-rw-r--r--block/blkverify.c4
2 files changed, 4 insertions, 4 deletions
diff --git a/block/blkdebug.c b/block/blkdebug.c
index 9b885359e4..a251802ad4 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -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;
}
diff --git a/block/blkverify.c b/block/blkverify.c
index 4ca8584b88..9d5f1ec5b9 100644
--- a/block/blkverify.c
+++ b/block/blkverify.c
@@ -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;
}