mirror of
https://github.com/dlang/phobos.git
synced 2025-04-27 13:40:20 +03:00
Fixing a memory leak
In the forked process, the array "pfds" is allocated and is never free'd. That's a problem if you're going to spawn and keep running a lot of processes, since it's a quite big array.
This commit is contained in:
parent
2deea50438
commit
cbb455fb34
1 changed files with 2 additions and 1 deletions
|
@ -1038,7 +1038,7 @@ private Pid spawnProcessPosix(scope const(char[])[] args,
|
|||
// signal safe functions list, but practically this should
|
||||
// not be a problem. Java VM and CPython also use malloc()
|
||||
// in its own implementation via opendir().
|
||||
import core.stdc.stdlib : malloc;
|
||||
import core.stdc.stdlib : malloc, free;
|
||||
import core.sys.posix.poll : pollfd, poll, POLLNVAL;
|
||||
import core.sys.posix.sys.resource : rlimit, getrlimit, RLIMIT_NOFILE;
|
||||
|
||||
|
@ -1055,6 +1055,7 @@ private Pid spawnProcessPosix(scope const(char[])[] args,
|
|||
|
||||
// Call poll() to see which ones are actually open:
|
||||
auto pfds = cast(pollfd*) malloc(pollfd.sizeof * maxToClose);
|
||||
scope(exit) free(pfds);
|
||||
if (pfds is null)
|
||||
{
|
||||
abortOnError(forkPipeOut, InternalError.malloc, .errno);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue