1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

security: Resolve possible memory leak

If virSecuritySELinuxRestoreFileLabel returns 0 or -1 too soon, then
the @newpath will be leaked.

Suggested-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
John Ferlan 2018-12-20 16:27:40 -05:00
parent c541177314
commit 458b952bee

View File

@ -1477,10 +1477,12 @@ virSecuritySELinuxRestoreFileLabel(virSecurityManagerPtr mgr,
goto cleanup;
}
if ((rc = virSecuritySELinuxTransactionAppend(path, NULL, false, true)) < 0)
return -1;
else if (rc > 0)
return 0;
if ((rc = virSecuritySELinuxTransactionAppend(path, NULL, false, true)) < 0) {
goto cleanup;
} else if (rc > 0) {
ret = 0;
goto cleanup;
}
if (recall) {
if ((rc = virSecuritySELinuxRecallLabel(newpath, &fcon)) < 0) {