expander: Fix file descriptor leak

Pointed by Infer static analyser.

Change-Id: Iaf79d58a963976a8ee6f7313c3d1902ff50ecf9e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7258
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
This commit is contained in:
Murai Takashi 2021-12-20 05:53:22 +09:00 committed by waddlesplash
parent dbe86e4638
commit cbf3fb528f

View File

@ -247,8 +247,10 @@ ExpanderThread::PipeCommand(int argc, const char** argv, int& in, int& out,
close(master);
setsid();
if (ioctl(slave, TIOCSCTTY, NULL) != 0)
if (ioctl(slave, TIOCSCTTY, NULL) != 0) {
close(slave);
return -1;
}
dup2(slave, 0);
close(slave);