From: مصطفي محمود كمال الدين <48567303+moste00(a)users.noreply.github.com>
---
src/libvirt-domain.c | 32 ++++++++------------------------
1 file changed, 8 insertions(+), 24 deletions(-)
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 83abad251e..9b68a7ac95 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -884,7 +884,7 @@ virDomainSave(virDomainPtr domain, const char *to)
if (conn->driver->domainSave) {
int ret;
- char *absolute_to;
+ g_autofree char *absolute_to;
/* We must absolutize the file path as the save is done out of process */
if (!(absolute_to = g_canonicalize_filename(to, NULL))) {
@@ -895,8 +895,6 @@ virDomainSave(virDomainPtr domain, const char *to)
ret = conn->driver->domainSave(domain, absolute_to);
- VIR_FREE(absolute_to);
-
if (ret < 0)
goto error;
return ret;
@@ -974,7 +972,7 @@ virDomainSaveFlags(virDomainPtr domain, const char *to,
if (conn->driver->domainSaveFlags) {
int ret;
- char *absolute_to;
+ g_autofree char *absolute_to;
/* We must absolutize the file path as the save is done out of process */
if (!(absolute_to = g_canonicalize_filename(to, NULL))) {
@@ -985,8 +983,6 @@ virDomainSaveFlags(virDomainPtr domain, const char *to,
ret = conn->driver->domainSaveFlags(domain, absolute_to, dxml, flags);
- VIR_FREE(absolute_to);
-
if (ret < 0)
goto error;
return ret;
@@ -1076,7 +1072,7 @@ virDomainRestore(virConnectPtr conn, const char *from)
if (conn->driver->domainRestore) {
int ret;
- char *absolute_from;
+ g_autofree char *absolute_from;
/* We must absolutize the file path as the restore is done out of process */
if (!(absolute_from = g_canonicalize_filename(from, NULL))) {
@@ -1087,8 +1083,6 @@ virDomainRestore(virConnectPtr conn, const char *from)
ret = conn->driver->domainRestore(conn, absolute_from);
- VIR_FREE(absolute_from);
-
if (ret < 0)
goto error;
return ret;
@@ -1156,7 +1150,7 @@ virDomainRestoreFlags(virConnectPtr conn, const char *from, const
char *dxml,
if (conn->driver->domainRestoreFlags) {
int ret;
- char *absolute_from;
+ g_autofree char *absolute_from;
/* We must absolutize the file path as the restore is done out of process */
if (!(absolute_from = g_canonicalize_filename(from, NULL))) {
@@ -1168,8 +1162,6 @@ virDomainRestoreFlags(virConnectPtr conn, const char *from, const
char *dxml,
ret = conn->driver->domainRestoreFlags(conn, absolute_from, dxml,
flags);
- VIR_FREE(absolute_from);
-
if (ret < 0)
goto error;
return ret;
@@ -1263,7 +1255,7 @@ virDomainSaveImageGetXMLDesc(virConnectPtr conn, const char *file,
if (conn->driver->domainSaveImageGetXMLDesc) {
char *ret;
- char *absolute_file;
+ g_autofree char *absolute_file;
/* We must absolutize the file path as the read is done out of process */
if (!(absolute_file = g_canonicalize_filename(file, NULL))) {
@@ -1275,8 +1267,6 @@ virDomainSaveImageGetXMLDesc(virConnectPtr conn, const char *file,
ret = conn->driver->domainSaveImageGetXMLDesc(conn, absolute_file,
flags);
- VIR_FREE(absolute_file);
-
if (!ret)
goto error;
return ret;
@@ -1338,7 +1328,7 @@ virDomainSaveImageDefineXML(virConnectPtr conn, const char *file,
if (conn->driver->domainSaveImageDefineXML) {
int ret;
- char *absolute_file;
+ g_autofree char *absolute_file;
/* We must absolutize the file path as the read is done out of process */
if (!(absolute_file = g_canonicalize_filename(file, NULL))) {
@@ -1350,8 +1340,6 @@ virDomainSaveImageDefineXML(virConnectPtr conn, const char *file,
ret = conn->driver->domainSaveImageDefineXML(conn, absolute_file,
dxml, flags);
- VIR_FREE(absolute_file);
-
if (ret < 0)
goto error;
return ret;
@@ -1415,7 +1403,7 @@ virDomainCoreDump(virDomainPtr domain, const char *to, unsigned int
flags)
if (conn->driver->domainCoreDump) {
int ret;
- char *absolute_to;
+ g_autofree char *absolute_to;
/* We must absolutize the file path as the save is done out of process */
if (!(absolute_to = g_canonicalize_filename(to, NULL))) {
@@ -1426,8 +1414,6 @@ virDomainCoreDump(virDomainPtr domain, const char *to, unsigned int
flags)
ret = conn->driver->domainCoreDump(domain, absolute_to, flags);
- VIR_FREE(absolute_to);
-
if (ret < 0)
goto error;
return ret;
@@ -1501,7 +1487,7 @@ virDomainCoreDumpWithFormat(virDomainPtr domain, const char *to,
if (conn->driver->domainCoreDumpWithFormat) {
int ret;
- char *absolute_to;
+ g_autofree char *absolute_to;
/* We must absolutize the file path as the save is done out of process */
if (!(absolute_to = g_canonicalize_filename(to, NULL))) {
@@ -1513,8 +1499,6 @@ virDomainCoreDumpWithFormat(virDomainPtr domain, const char *to,
ret = conn->driver->domainCoreDumpWithFormat(domain, absolute_to,
dumpformat, flags);
- VIR_FREE(absolute_to);
-
if (ret < 0)
goto error;
return ret;
--
2.34.1