提交 5483e573 编写于 作者: A Alex Jia 提交者: Eric Blake

util: Plug memory leak on virNetDevBridgeGet() sucessful path

Detected by Coverity. Leak introduced in commit c1df2c14.

Two bugs here:
1. memory leak on successful parse
2. failure to parse still returned success
Signed-off-by: NAlex Jia <ajia@redhat.com>
Signed-off-by: NEric Blake <eblake@redhat.com>
上级 d7cc2520
......@@ -161,13 +161,18 @@ static int virNetDevBridgeGet(const char *brname,
if (virFileExists(path)) {
char *valuestr;
if (virFileReadAll(path, INT_BUFSIZE_BOUND(unsigned long), &valuestr) < 0)
if (virFileReadAll(path, INT_BUFSIZE_BOUND(unsigned long),
&valuestr) < 0)
goto cleanup;
if (virStrToLong_ul(valuestr, NULL, 10, value) < 0) {
virReportSystemError(EINVAL,
_("Unable to get bridge %s %s"), brname, paramname);
_("Unable to get bridge %s %s"),
brname, paramname);
VIR_FREE(valuestr);
goto cleanup;
}
VIR_FREE(valuestr);
} else {
struct __bridge_info info;
unsigned long args[] = { BRCTL_GET_BRIDGE_INFO, (unsigned long)&info, 0, 0 };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册