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>
This commit is contained in:
Stefan Hajnoczi 2012-01-16 09:28:06 +00:00 committed by Kevin Wolf
parent bd60324706
commit 031380d877
3 changed files with 28 additions and 28 deletions

View file

@ -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;
}