Commit 35d8e02
fs: Handle case where old FD == new FD in fs_dup2()
Previously, when the same FD was passed as both the new and old FD to
fs_dup2(), the algorithm would close the FD then try to get a reference
to a NULL pointer.
Address this issue by following the POSIX spec, and return the FD
directly, with its reference count incremented.
Signed-off-by: Paul Cercueil <paul@crapouillou.net>1 parent 607d1a8 commit 35d8e02
1 file changed
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
309 | 309 | | |
310 | 310 | | |
311 | 311 | | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
312 | 315 | | |
313 | 316 | | |
314 | 317 | | |
| |||
319 | 322 | | |
320 | 323 | | |
321 | 324 | | |
| 325 | + | |
322 | 326 | | |
323 | 327 | | |
324 | 328 | | |
| |||
0 commit comments