Corrections in cleanup code in process_clone
Since we are done cloning the generic part of the process, it
is proper to simply call private_process_destroy on failures.
If os_process_clone passed, but arch_process_clone fails,
os_process_destroy must be called.
diff --git a/proc.c b/proc.c
index cc45882..74b8ed5 100644
--- a/proc.c
+++ b/proc.c
@@ -407,7 +407,6 @@
if (nargs == NULL
|| val_dict_clone(nargs, args) < 0) {
size_t j;
- fail4:
for (j = 0; j < i; ++j) {
nargs = retp->callstack[i].arguments;
val_dict_destroy(nargs);
@@ -435,9 +434,17 @@
}
}
- if (os_process_clone(retp, proc) < 0
- || arch_process_clone(retp, proc) < 0)
- goto fail4;
+ /* At this point, retp is fully initialized, except for OS and
+ * arch parts, and we can call private_process_destroy. */
+ if (os_process_clone(retp, proc) < 0) {
+ private_process_destroy(retp, 0);
+ return -1;
+ }
+ if (arch_process_clone(retp, proc) < 0) {
+ os_process_destroy(retp);
+ private_process_destroy(retp, 0);
+ return -1;
+ }
return 0;
}