mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
util: Plug memory leak on virNetDevBridgeGet() sucessful path
Detected by Coverity. Leak introduced in commit c1df2c1
.
Two bugs here:
1. memory leak on successful parse
2. failure to parse still returned success
Signed-off-by: Alex Jia <ajia@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
d7cc2520f2
commit
5483e5736d
@ -161,13 +161,18 @@ static int virNetDevBridgeGet(const char *brname,
|
|||||||
|
|
||||||
if (virFileExists(path)) {
|
if (virFileExists(path)) {
|
||||||
char *valuestr;
|
char *valuestr;
|
||||||
if (virFileReadAll(path, INT_BUFSIZE_BOUND(unsigned long), &valuestr) < 0)
|
if (virFileReadAll(path, INT_BUFSIZE_BOUND(unsigned long),
|
||||||
|
&valuestr) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virStrToLong_ul(valuestr, NULL, 10, value) < 0) {
|
if (virStrToLong_ul(valuestr, NULL, 10, value) < 0) {
|
||||||
virReportSystemError(EINVAL,
|
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 {
|
} else {
|
||||||
struct __bridge_info info;
|
struct __bridge_info info;
|
||||||
unsigned long args[] = { BRCTL_GET_BRIDGE_INFO, (unsigned long)&info, 0, 0 };
|
unsigned long args[] = { BRCTL_GET_BRIDGE_INFO, (unsigned long)&info, 0, 0 };
|
||||||
|
Loading…
Reference in New Issue
Block a user