提交 80cba1b7 编写于 作者: S Stefan Weil 提交者: Michael Tokarev

hw/9pfs: Fix potential memory leak and avoid reuse of freed memory

The leak was reported by cppcheck.

Function proxy_init also calls g_free for ctx->fs_root.
Avoid reuse of this memory by setting ctx->fs_root to NULL.
Signed-off-by: NStefan Weil <sw@weilnetz.de>
Reviewed-by: NM. Mohan Kumar <mohan@in.ibm.com>
Signed-off-by: NMichael Tokarev <mjt@tls.msk.ru>
上级 d9cd4007
......@@ -1153,10 +1153,12 @@ static int proxy_init(FsContext *ctx)
sock_id = atoi(ctx->fs_root);
if (sock_id < 0) {
fprintf(stderr, "socket descriptor not initialized\n");
g_free(proxy);
return -1;
}
}
g_free(ctx->fs_root);
ctx->fs_root = NULL;
proxy->in_iovec.iov_base = g_malloc(PROXY_MAX_IO_SZ + PROXY_HDR_SZ);
proxy->in_iovec.iov_len = PROXY_MAX_IO_SZ + PROXY_HDR_SZ;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册