]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Revert "esx: switch VIR_FREE->g_free in esx*Free*()"
authorMartin Kletzander <mkletzan@redhat.com>
Thu, 14 May 2026 13:52:53 +0000 (15:52 +0200)
committerMartin Kletzander <mkletzan@redhat.com>
Thu, 14 May 2026 15:52:21 +0000 (17:52 +0200)
This reverts commit 443c79dd7f7d4051fc0084baaa6c56a55d2aace4.

Change from VIR_FREE() to g_free meant there is a possible double free
when there is an error during parsing because the parsing it done
directly into the parsedUri member of the esxPrivate, free'd when it
fails and then the caller calls free on it again.  Changing back to
VIR_FREE() means there is no double free and no crash.

Reproducible easily with `virsh -c esx://l?no_verify=2`.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
src/esx/esx_driver.c
src/esx/esx_stream.c
src/esx/esx_util.c

index 010c62b8e880b89e02bc31799c8ed4db266849bf..6ff0db48ac02006e0149dfe5eae501d01fa6b404 100644 (file)
@@ -63,7 +63,7 @@ esxFreePrivate(esxPrivate **priv)
     esxUtil_FreeParsedUri(&(*priv)->parsedUri);
     virObjectUnref((*priv)->caps);
     virObjectUnref((*priv)->xmlopt);
-    g_free(*priv);
+    VIR_FREE(*priv);
 }
 
 
index 143b2405ed4961ac7a5d3730460396412d837135..c1dd80806febfd68c03fe6222112ac8034f70ca3 100644 (file)
@@ -321,8 +321,8 @@ esxFreeStreamPrivate(esxStreamPrivate **priv)
         return;
 
     esxVI_CURL_Free(&(*priv)->curl);
-    g_free((*priv)->backlog);
-    g_free(*priv);
+    VIR_FREE((*priv)->backlog);
+    VIR_FREE(*priv);
 }
 
 static int
index a6275babd5423fb2056e278cfa13ea8bf5f17674..1443ec3b9e468fbd1963c1513283f5073f7dcb46 100644 (file)
@@ -165,13 +165,14 @@ esxUtil_FreeParsedUri(esxUtil_ParsedUri **parsedUri)
     if (!parsedUri || !(*parsedUri))
         return;
 
-    g_free((*parsedUri)->transport);
-    g_free((*parsedUri)->vCenter);
-    g_free((*parsedUri)->proxy_hostname);
-    g_free((*parsedUri)->path);
-    g_free((*parsedUri)->cacert);
 
-    g_free(*parsedUri);
+    VIR_FREE((*parsedUri)->transport);
+    VIR_FREE((*parsedUri)->vCenter);
+    VIR_FREE((*parsedUri)->proxy_hostname);
+    VIR_FREE((*parsedUri)->path);
+    VIR_FREE((*parsedUri)->cacert);
+
+    VIR_FREE(*parsedUri);
 }