mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-01 20:29:00 +00:00
system/popen: close newfd correctly
Fixes a bug where newfd is not properly closed when newfd[0] equals newfd[1]. This can cause file descriptor leaks in certain edge cases where the read and write sides of the pipe are duplicated. Signed-off-by: hongfengchen <hongfengchen@xiaomi.com>
This commit is contained in:
parent
f16a45a854
commit
b72f7997a3
1 changed files with 1 additions and 1 deletions
|
|
@ -312,7 +312,7 @@ FILE *popen(FAR const char *command, FAR const char *mode)
|
|||
|
||||
close(newfd[0]);
|
||||
|
||||
if (rw)
|
||||
if (rw && newfd[0] != newfd[1])
|
||||
{
|
||||
close(newfd[1]);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue