Skip to content

Commit

Permalink
esx: reorder code to avoid need to VIR_FREE mimeType
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Michal Privoznik <[email protected]>
  • Loading branch information
Laine Stump committed Feb 16, 2021
1 parent 33d3ebf commit 0a69fa6
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/esx/esx_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down

0 comments on commit 0a69fa6

Please sign in to comment.