]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
esx: reorder code to avoid need to VIR_FREE mimeType
authorLaine Stump <laine@redhat.com>
Fri, 12 Feb 2021 19:22:21 +0000 (14:22 -0500)
committerLaine Stump <laine@redhat.com>
Tue, 16 Feb 2021 18:50:05 +0000 (13:50 -0500)
mimeType is initialized to NULL, and then only set in one place, just
before a check (not involving mimeType) that then VIR_FREEs mimeType
if it fails. If we just reorder the code to do the check prior to
setting mimeType, then there won't be any need to VIR_FREE(mimeType)
on failure (because it will already be empty/NULL).

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/esx/esx_driver.c

index 47873c0d54470e7445caee58f002a1ae36150ca5..2d010096a526260d8e30669e2bb1f1af55f6da39 100644 (file)
@@ -2374,12 +2374,10 @@ esxDomainScreenshot(virDomainPtr domain, virStreamPtr stream,
 
     url = virBufferContentAndReset(&buffer);
 
-    mimeType = g_strdup("image/png");
-
-    if (esxStreamOpenDownload(stream, priv, url, 0, 0) < 0) {
-        VIR_FREE(mimeType);
+    if (esxStreamOpenDownload(stream, priv, url, 0, 0) < 0)
         goto cleanup;
-    }
+
+    mimeType = g_strdup("image/png");
 
  cleanup: