@@ -37,7 +37,7 @@ int ProcessStatus::get_fatal_signal() {
3737ProcessStatus invoke_in_subprocess (FunctionCaller *func, unsigned timeout_ms) {
3838 int pipe_fds[2 ];
3939 if (::pipe (pipe_fds) == -1 ) {
40- ::free ( func) ;
40+ delete func;
4141 return ProcessStatus::error (" pipe(2) failed" );
4242 }
4343
@@ -46,13 +46,13 @@ ProcessStatus invoke_in_subprocess(FunctionCaller *func, unsigned timeout_ms) {
4646 ::fflush (stdout);
4747 pid_t pid = ::fork ();
4848 if (pid == -1 ) {
49- ::free ( func) ;
49+ delete func;
5050 return ProcessStatus::error (" fork(2) failed" );
5151 }
5252
5353 if (!pid) {
5454 (*func)();
55- ::free ( func) ;
55+ delete func;
5656 ::exit (0 );
5757 }
5858 ::close (pipe_fds[1 ]);
@@ -63,13 +63,13 @@ ProcessStatus invoke_in_subprocess(FunctionCaller *func, unsigned timeout_ms) {
6363 // No events requested so this call will only return after the timeout or if
6464 // the pipes peer was closed, signaling the process exited.
6565 if (::poll (&poll_fd, 1 , timeout_ms) == -1 ) {
66- ::free ( func) ;
66+ delete func;
6767 return ProcessStatus::error (" poll(2) failed" );
6868 }
6969 // If the pipe wasn't closed by the child yet then timeout has expired.
7070 if (!(poll_fd.revents & POLLHUP)) {
7171 ::kill (pid, SIGKILL);
72- ::free ( func) ;
72+ delete func;
7373 return ProcessStatus::timed_out_ps ();
7474 }
7575
@@ -78,11 +78,11 @@ ProcessStatus invoke_in_subprocess(FunctionCaller *func, unsigned timeout_ms) {
7878 // and doesn't turn into a zombie.
7979 pid_t status = ::waitpid (pid, &wstatus, 0 );
8080 if (status == -1 ) {
81- ::free ( func) ;
81+ delete func;
8282 return ProcessStatus::error (" waitpid(2) failed" );
8383 }
8484 assert (status == pid);
85- ::free ( func) ;
85+ delete func;
8686 return {wstatus};
8787}
8888
0 commit comments