This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
POSIX: Check fds against negatives.
[perl5.git] / ext / POSIX / typemap
index 45a9fc7..753afcd 100644 (file)
@@ -15,6 +15,7 @@ POSIX::SigSet         T_OPAQUEPTROBJ
 POSIX::Termios         T_OPAQUEPTROBJ
 POSIX::SigAction       T_HVREF
 POSIX::SigNo           T_SIGNO
 POSIX::Termios         T_OPAQUEPTROBJ
 POSIX::SigAction       T_HVREF
 POSIX::SigNo           T_SIGNO
+POSIX::Fd              T_FD
 
 INPUT
 T_OPAQUEPTROBJ
 
 INPUT
 T_OPAQUEPTROBJ
@@ -35,6 +36,12 @@ T_SIGNO
                                    sig);
        }
 
                                    sig);
        }
 
+T_FD
+       if ((fd = (int)SvIV($arg)) < 0) {
+            SETERRNO(EBADF, RMS_IFI);
+            XSRETURN_IV(-1);
+       }
+
 OUTPUT
 T_OPAQUEPTROBJ
        sv_setref_pvn($arg, \"${ntype}\", (const char*)$var, sizeof(*$var));
 OUTPUT
 T_OPAQUEPTROBJ
        sv_setref_pvn($arg, \"${ntype}\", (const char*)$var, sizeof(*$var));