Bug 1172467: Fix an IPC channel file descriptor leak from Nuwa to the child process. r=khuey

This commit is contained in:
Cervantes Yu 2015-07-07 12:10:05 +08:00
parent e3ecdbc77a
commit 9335f69953

View File

@ -375,17 +375,16 @@ ProcLoaderLoadRunner::ShuffleFds()
MOZ_ASSERT(mFdsRemap.Length() <= kReservedFileDescriptors);
InjectiveMultimap fd_shuffle1, fd_shuffle2;
fd_shuffle1.reserve(mFdsRemap.Length());
fd_shuffle2.reserve(mFdsRemap.Length());
InjectiveMultimap fd_shuffle;
fd_shuffle.reserve(mFdsRemap.Length());
for (i = 0; i < mFdsRemap.Length(); i++) {
const FDRemap *map = &mFdsRemap[i];
int fd = map->fd().PlatformHandle();
int tofd = map->mapto();
fd_shuffle1.push_back(InjectionArc(fd, tofd, false));
fd_shuffle2.push_back(InjectionArc(fd, tofd, false));
// The FD that is dup2()'d from needs to be closed after shuffling.
fd_shuffle.push_back(InjectionArc(fd, tofd, /*in_close=*/true));
// Erase from sReservedFds we will use.
for (int* toErase = sReservedFds->begin();
@ -398,7 +397,7 @@ ProcLoaderLoadRunner::ShuffleFds()
}
}
DebugOnly<bool> ok = ShuffleFileDescriptors(&fd_shuffle1);
DebugOnly<bool> ok = ShuffleFileDescriptors(&fd_shuffle);
// Close the FDs that are reserved but not used after
// ShuffleFileDescriptors().