mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-26 13:22:20 +00:00
fixes for several memory leaks
Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
a9f35c4863
commit
5a81401235
1
AUTHORS
1
AUTHORS
@ -156,6 +156,7 @@ Patches have also been contributed by:
|
|||||||
Michal Novotny <minovotn@redhat.com>
|
Michal Novotny <minovotn@redhat.com>
|
||||||
Christophe Fergeau <teuf@gnome.org>
|
Christophe Fergeau <teuf@gnome.org>
|
||||||
Markus Groß <gross@univention.de>
|
Markus Groß <gross@univention.de>
|
||||||
|
Phil Petty <phpetty@cisco.com>
|
||||||
|
|
||||||
[....send patches to get your name here....]
|
[....send patches to get your name here....]
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* secret_conf.c: internal <secret> XML handling
|
* secret_conf.c: internal <secret> XML handling
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009 Red Hat, Inc.
|
* Copyright (C) 2009, 2011 Red Hat, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -182,6 +182,7 @@ secretXMLParseNode(xmlDocPtr xml, xmlNodePtr root)
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(prop);
|
VIR_FREE(prop);
|
||||||
|
VIR_FREE(uuidstr);
|
||||||
virSecretDefFree(def);
|
virSecretDefFree(def);
|
||||||
xmlXPathFreeContext(ctxt);
|
xmlXPathFreeContext(ctxt);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* nwfilter_gentech_driver.c: generic technology driver
|
* nwfilter_gentech_driver.c: generic technology driver
|
||||||
*
|
*
|
||||||
|
* Copyright (C) 2011 Red Hat, Inc.
|
||||||
* Copyright (C) 2010 IBM Corp.
|
* Copyright (C) 2010 IBM Corp.
|
||||||
* Copyright (C) 2010 Stefan Berger
|
* Copyright (C) 2010 Stefan Berger
|
||||||
*
|
*
|
||||||
@ -660,8 +661,6 @@ virNWFilterInstantiate(virConnectPtr conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
virNWFilterUnlockIface(ifname);
|
virNWFilterUnlockIface(ifname);
|
||||||
|
|
||||||
VIR_FREE(ptrs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err_exit:
|
err_exit:
|
||||||
@ -670,6 +669,7 @@ err_exit:
|
|||||||
virNWFilterRuleInstFree(insts[j]);
|
virNWFilterRuleInstFree(insts[j]);
|
||||||
|
|
||||||
VIR_FREE(insts);
|
VIR_FREE(insts);
|
||||||
|
VIR_FREE(ptrs);
|
||||||
|
|
||||||
virNWFilterHashTableFree(missing_vars);
|
virNWFilterHashTableFree(missing_vars);
|
||||||
|
|
||||||
|
@ -479,22 +479,27 @@ doRemoteOpen (virConnectPtr conn,
|
|||||||
for (i = 0; i < vars->n; i++) {
|
for (i = 0; i < vars->n; i++) {
|
||||||
var = &vars->p[i];
|
var = &vars->p[i];
|
||||||
if (STRCASEEQ (var->name, "name")) {
|
if (STRCASEEQ (var->name, "name")) {
|
||||||
|
VIR_FREE(name);
|
||||||
name = strdup (var->value);
|
name = strdup (var->value);
|
||||||
if (!name) goto out_of_memory;
|
if (!name) goto out_of_memory;
|
||||||
var->ignore = 1;
|
var->ignore = 1;
|
||||||
} else if (STRCASEEQ (var->name, "command")) {
|
} else if (STRCASEEQ (var->name, "command")) {
|
||||||
|
VIR_FREE(command);
|
||||||
command = strdup (var->value);
|
command = strdup (var->value);
|
||||||
if (!command) goto out_of_memory;
|
if (!command) goto out_of_memory;
|
||||||
var->ignore = 1;
|
var->ignore = 1;
|
||||||
} else if (STRCASEEQ (var->name, "socket")) {
|
} else if (STRCASEEQ (var->name, "socket")) {
|
||||||
|
VIR_FREE(sockname);
|
||||||
sockname = strdup (var->value);
|
sockname = strdup (var->value);
|
||||||
if (!sockname) goto out_of_memory;
|
if (!sockname) goto out_of_memory;
|
||||||
var->ignore = 1;
|
var->ignore = 1;
|
||||||
} else if (STRCASEEQ (var->name, "auth")) {
|
} else if (STRCASEEQ (var->name, "auth")) {
|
||||||
|
VIR_FREE(authtype);
|
||||||
authtype = strdup (var->value);
|
authtype = strdup (var->value);
|
||||||
if (!authtype) goto out_of_memory;
|
if (!authtype) goto out_of_memory;
|
||||||
var->ignore = 1;
|
var->ignore = 1;
|
||||||
} else if (STRCASEEQ (var->name, "netcat")) {
|
} else if (STRCASEEQ (var->name, "netcat")) {
|
||||||
|
VIR_FREE(netcat);
|
||||||
netcat = strdup (var->value);
|
netcat = strdup (var->value);
|
||||||
if (!netcat) goto out_of_memory;
|
if (!netcat) goto out_of_memory;
|
||||||
var->ignore = 1;
|
var->ignore = 1;
|
||||||
@ -511,6 +516,7 @@ doRemoteOpen (virConnectPtr conn,
|
|||||||
else
|
else
|
||||||
priv->debugLog = stderr;
|
priv->debugLog = stderr;
|
||||||
} else if (STRCASEEQ(var->name, "pkipath")) {
|
} else if (STRCASEEQ(var->name, "pkipath")) {
|
||||||
|
VIR_FREE(pkipath);
|
||||||
pkipath = strdup(var->value);
|
pkipath = strdup(var->value);
|
||||||
if (!pkipath) goto out_of_memory;
|
if (!pkipath) goto out_of_memory;
|
||||||
var->ignore = 1;
|
var->ignore = 1;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* conf.c: parser for a subset of the Python encoded Xen configuration files
|
* conf.c: parser for a subset of the Python encoded Xen configuration files
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006, 2007, 2008, 2009, 2010 Red Hat, Inc.
|
* Copyright (C) 2006-2011 Red Hat, Inc.
|
||||||
*
|
*
|
||||||
* See COPYING.LIB for the License of this software
|
* See COPYING.LIB for the License of this software
|
||||||
*
|
*
|
||||||
@ -648,22 +648,23 @@ virConfParseStatement(virConfParserCtxtPtr ctxt)
|
|||||||
|
|
||||||
SKIP_BLANKS_AND_EOL;
|
SKIP_BLANKS_AND_EOL;
|
||||||
if (CUR == '#') {
|
if (CUR == '#') {
|
||||||
return(virConfParseComment(ctxt));
|
return virConfParseComment(ctxt);
|
||||||
}
|
}
|
||||||
name = virConfParseName(ctxt);
|
name = virConfParseName(ctxt);
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
return(-1);
|
return -1;
|
||||||
SKIP_BLANKS;
|
SKIP_BLANKS;
|
||||||
if (CUR != '=') {
|
if (CUR != '=') {
|
||||||
virConfError(ctxt, VIR_ERR_CONF_SYNTAX, _("expecting an assignment"));
|
virConfError(ctxt, VIR_ERR_CONF_SYNTAX, _("expecting an assignment"));
|
||||||
return(-1);
|
VIR_FREE(name);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
NEXT;
|
NEXT;
|
||||||
SKIP_BLANKS;
|
SKIP_BLANKS;
|
||||||
value = virConfParseValue(ctxt);
|
value = virConfParseValue(ctxt);
|
||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
VIR_FREE(name);
|
VIR_FREE(name);
|
||||||
return(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
SKIP_BLANKS;
|
SKIP_BLANKS;
|
||||||
if (CUR == '#') {
|
if (CUR == '#') {
|
||||||
@ -675,16 +676,16 @@ virConfParseStatement(virConfParserCtxtPtr ctxt)
|
|||||||
virReportOOMError();
|
virReportOOMError();
|
||||||
VIR_FREE(name);
|
VIR_FREE(name);
|
||||||
virConfFreeValue(value);
|
virConfFreeValue(value);
|
||||||
return(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (virConfAddEntry(ctxt->conf, name, value, comm) == NULL) {
|
if (virConfAddEntry(ctxt->conf, name, value, comm) == NULL) {
|
||||||
VIR_FREE(name);
|
VIR_FREE(name);
|
||||||
virConfFreeValue(value);
|
virConfFreeValue(value);
|
||||||
VIR_FREE(comm);
|
VIR_FREE(comm);
|
||||||
return(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
return(0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* storage_file.c: file utility functions for FS storage backend
|
* storage_file.c: file utility functions for FS storage backend
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2010 Red Hat, Inc.
|
* Copyright (C) 2007-2011 Red Hat, Inc.
|
||||||
* Copyright (C) 2007-2008 Daniel P. Berrange
|
* Copyright (C) 2007-2008 Daniel P. Berrange
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
@ -838,8 +838,9 @@ virStorageFileGetMetadataFromFD(const char *path,
|
|||||||
|
|
||||||
if (format < 0 ||
|
if (format < 0 ||
|
||||||
format >= VIR_STORAGE_FILE_LAST) {
|
format >= VIR_STORAGE_FILE_LAST) {
|
||||||
virReportSystemError(EINVAL, _("unknown storage file format %d"), format);
|
virReportSystemError(EINVAL, _("unknown storage file format %d"),
|
||||||
return -1;
|
format);
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = virStorageFileGetMetadataFromBuf(format, path, head, len, meta);
|
ret = virStorageFileGetMetadataFromBuf(format, path, head, len, meta);
|
||||||
|
@ -105,9 +105,10 @@ virXPathStringLimit(const char *xpath,
|
|||||||
|
|
||||||
if (tmp != NULL && strlen(tmp) >= maxlen) {
|
if (tmp != NULL && strlen(tmp) >= maxlen) {
|
||||||
virXMLError(VIR_ERR_INTERNAL_ERROR,
|
virXMLError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("\'%s\' value longer than %zd bytes in virXPathStringLimit()"),
|
_("\'%s\' value longer than %zd bytes"),
|
||||||
xpath, maxlen);
|
xpath, maxlen);
|
||||||
return NULL;
|
VIR_FREE(tmp);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return tmp;
|
return tmp;
|
||||||
|
@ -9518,6 +9518,8 @@ cmdCd(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
|
|||||||
{
|
{
|
||||||
const char *dir;
|
const char *dir;
|
||||||
int found;
|
int found;
|
||||||
|
int ret = TRUE;
|
||||||
|
bool dir_malloced = false;
|
||||||
|
|
||||||
if (!ctl->imode) {
|
if (!ctl->imode) {
|
||||||
vshError(ctl, "%s", _("cd: command valid only in interactive mode"));
|
vshError(ctl, "%s", _("cd: command valid only in interactive mode"));
|
||||||
@ -9528,16 +9530,19 @@ cmdCd(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
|
|||||||
if (!found) {
|
if (!found) {
|
||||||
uid_t uid = geteuid();
|
uid_t uid = geteuid();
|
||||||
dir = virGetUserDirectory(uid);
|
dir = virGetUserDirectory(uid);
|
||||||
|
dir_malloced = !!dir;
|
||||||
}
|
}
|
||||||
if (!dir)
|
if (!dir)
|
||||||
dir = "/";
|
dir = "/";
|
||||||
|
|
||||||
if (chdir (dir) == -1) {
|
if (chdir(dir) == -1) {
|
||||||
vshError(ctl, _("cd: %s: %s"), strerror(errno), dir);
|
vshError(ctl, _("cd: %s: %s"), strerror(errno), dir);
|
||||||
return FALSE;
|
ret = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
if (dir_malloced)
|
||||||
|
VIR_FREE(dir);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user