mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
mrb_dup() should fail if fd is a negative integer; ref #4005
This commit is contained in:
@@ -542,12 +542,12 @@ mrb_dup(mrb_state *mrb, int fd, mrb_bool *failed)
|
||||
{
|
||||
int new_fd;
|
||||
|
||||
*failed = FALSE;
|
||||
*failed = TRUE;
|
||||
if (fd < 0)
|
||||
return fd;
|
||||
|
||||
new_fd = dup(fd);
|
||||
if (new_fd == -1) *failed = TRUE;
|
||||
if (new_fd > 0) *failed = FALSE;
|
||||
return new_fd;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user