mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
Fix numerous memory leaks
This commit is contained in:
parent
b4f841d92f
commit
2b3c49b6ab
@ -1,3 +1,12 @@
|
||||
Sat Dec 1 10:42:34 EST 2007 Daniel P. Berrange <berrange@redhat.com>
|
||||
|
||||
* src/hash.c: reset error object when releasing connection
|
||||
* src/iptables.c: don't strdup() param passed to strcmp()
|
||||
* src/qemu_driver.c: free TLS directory path in driver shutdown
|
||||
* src/remote_internal.c: don't strdup() params for virRaiseError
|
||||
* src/virsh.c: reset global error object at shutdown. Release
|
||||
connection state during abnormal shutdown
|
||||
|
||||
Sat Dec 1 10:22:34 EST 2007 Daniel P. Berrange <berrange@redhat.com>
|
||||
|
||||
* src/qemu_driver.c: Fix off-by-1 buffer NULL termination in
|
||||
|
@ -726,6 +726,7 @@ virFreeConnect(virConnectPtr conn) {
|
||||
virHashFree(conn->networks, (virHashDeallocator) virNetworkFreeName);
|
||||
if (conn->hashes_mux != NULL)
|
||||
xmlFreeMutex(conn->hashes_mux);
|
||||
virResetError(&conn->err);
|
||||
free(conn);
|
||||
return(0);
|
||||
}
|
||||
|
@ -246,7 +246,7 @@ iptRulesRemove(iptRules *rules,
|
||||
int i;
|
||||
|
||||
for (i = 0; i < rules->nrules; i++)
|
||||
if (!strcmp(rules->rules[i].rule, strdup(rule)))
|
||||
if (!strcmp(rules->rules[i].rule, rule))
|
||||
break;
|
||||
|
||||
if (i >= rules->nrules)
|
||||
|
@ -341,6 +341,9 @@ qemudShutdown(void) {
|
||||
if (qemu_driver->networkAutostartDir)
|
||||
free(qemu_driver->networkAutostartDir);
|
||||
|
||||
if (qemu_driver->vncTLSx509certdir)
|
||||
free(qemu_driver->vncTLSx509certdir);
|
||||
|
||||
if (qemu_driver->brctl)
|
||||
brShutdown(qemu_driver->brctl);
|
||||
if (qemu_driver->iptables)
|
||||
|
@ -3052,20 +3052,13 @@ server_error (virConnectPtr conn, remote_error *err)
|
||||
dom = err->dom ? get_nonnull_domain (conn, *err->dom) : NULL;
|
||||
net = err->net ? get_nonnull_network (conn, *err->net) : NULL;
|
||||
|
||||
/* These strings are nullable. OK to ignore the return value
|
||||
* of strdup since these strings are informational.
|
||||
*/
|
||||
char *str1 = err->str1 ? strdup (*err->str1) : NULL;
|
||||
char *str2 = err->str2 ? strdup (*err->str2) : NULL;
|
||||
char *str3 = err->str3 ? strdup (*err->str3) : NULL;
|
||||
|
||||
char *message = err->message ? strdup (*err->message) : NULL;
|
||||
|
||||
__virRaiseError (conn, dom, net,
|
||||
err->domain, err->code, err->level,
|
||||
str1, str2, str3,
|
||||
err->str1 ? *err->str1 : NULL,
|
||||
err->str2 ? *err->str2 : NULL,
|
||||
err->str3 ? *err->str3 : NULL,
|
||||
err->int1, err->int2,
|
||||
"%s", message);
|
||||
"%s", err->message ? *err->message : NULL);
|
||||
}
|
||||
|
||||
/* get_nonnull_domain and get_nonnull_network turn an on-wire
|
||||
|
13
src/virsh.c
13
src/virsh.c
@ -4780,7 +4780,8 @@ static int
|
||||
vshDeinit(vshControl * ctl)
|
||||
{
|
||||
vshCloseLogFile(ctl);
|
||||
|
||||
if (ctl->name)
|
||||
free(ctl->name);
|
||||
if (ctl->conn) {
|
||||
if (virConnectClose(ctl->conn) != 0) {
|
||||
ctl->conn = NULL; /* prevent recursive call from vshError() */
|
||||
@ -4788,6 +4789,8 @@ vshDeinit(vshControl * ctl)
|
||||
"failed to disconnect from the hypervisor");
|
||||
}
|
||||
}
|
||||
virResetLastError();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -4985,11 +4988,15 @@ main(int argc, char **argv)
|
||||
ctl->name = strdup(defaultConn);
|
||||
}
|
||||
|
||||
if (!vshParseArgv(ctl, argc, argv))
|
||||
if (!vshParseArgv(ctl, argc, argv)) {
|
||||
vshDeinit(ctl);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (!vshInit(ctl))
|
||||
if (!vshInit(ctl)) {
|
||||
vshDeinit(ctl);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (!ctl->imode) {
|
||||
ret = vshCommandRun(ctl, ctl->cmd);
|
||||
|
Loading…
Reference in New Issue
Block a user