mirror of
https://github.com/X11Libre/xserver.git
synced 2026-09-11 18:42:23 +00:00
enhance: popen-fdopen-error-handling
If fdopen() fails, close the unused pipe fd, free the pid list node, and restore the smart scheduler signal before returning NULL. Previously the fd would leak and the node would be added to pidlist with a NULL fp. Signed-off-by: dongshengyuan <545258830@qq.com> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2236>
This commit is contained in:
parent
31ba120698
commit
dc638fbda0
1 changed files with 13 additions and 0 deletions
13
os/utils.c
13
os/utils.c
|
|
@ -1111,10 +1111,23 @@ Popen(const char *command, const char *type)
|
|||
if (*type == 'r') {
|
||||
iop = fdopen(pdes[0], type);
|
||||
close(pdes[1]);
|
||||
if (!iop)
|
||||
close(pdes[0]);
|
||||
}
|
||||
else {
|
||||
iop = fdopen(pdes[1], type);
|
||||
close(pdes[0]);
|
||||
if (!iop)
|
||||
close(pdes[1]);
|
||||
}
|
||||
|
||||
if (!iop) {
|
||||
free(cur);
|
||||
#ifdef HAVE_SETITIMER
|
||||
if (SmartScheduleEnable() < 0)
|
||||
perror("signal");
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cur->fp = iop;
|
||||
|
|
|
|||
Loading…
Reference in a new issue