1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-22 17:34:18 +03:00

commandhelper: Consolidate error paths

Preparation for later conversion to g_auto* memory handling.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Tim Wiederhake 2021-02-01 12:27:48 +01:00 committed by Peter Krempa
parent d274092131
commit 8d57776702

View File

@ -71,7 +71,7 @@ int main(int argc, char **argv) {
ssize_t got;
if (!log)
return ret;
goto cleanup;
for (i = 1; i < argc; i++) {
fprintf(log, "ARG:%s\n", argv[i]);
@ -89,7 +89,7 @@ int main(int argc, char **argv) {
}
if (!(newenv = malloc(sizeof(*newenv) * n)))
abort();
goto cleanup;
for (i = 0; i < n; i++) {
newenv[i] = environ[i];
@ -232,8 +232,10 @@ int main(int argc, char **argv) {
cleanup:
for (i = 0; i < G_N_ELEMENTS(buffers); i++)
free(buffers[i]);
fclose(log);
free(newenv);
if (newenv)
free(newenv);
if (log)
fclose(log);
return ret;
}