diff options
author | Petr Machata <pmachata@redhat.com> | 2012-10-27 19:29:00 +0200 |
---|---|---|
committer | Petr Machata <pmachata@redhat.com> | 2012-10-27 19:29:00 +0200 |
commit | 5bf471403f1145fb004005b99eb439969d672dcd (patch) | |
tree | 584a897b93ae79f6a4ce751d67d38efec721d30e /proc.c | |
parent | 81bc82ca194af8b6eccbbdf043e34e14bde0c34c (diff) | |
download | ltrace-5bf471403f1145fb004005b99eb439969d672dcd.tar.gz |
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.
Diffstat (limited to 'proc.c')
-rw-r--r-- | proc.c | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -407,7 +407,6 @@ process_clone(struct Process *retp, struct Process *proc, pid_t pid) 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 @@ process_clone(struct Process *retp, struct Process *proc, pid_t pid) } } - 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; } |