--- IO-AIO/AIO.xs 2008/10/22 18:15:36 1.133 +++ IO-AIO/AIO.xs 2009/04/19 13:05:06 1.134 @@ -657,9 +657,13 @@ STRLEN svlen; char *svptr = SvPVbyte (data, svlen); UV len = SvUV (length); + int fd; + + if (SvTYPE (data) > SVt_PVMG) + croak ("illegal data argument '%s', must be plain scalar string", SvPV_nolen (data)); SvUPGRADE (data, SVt_PV); - SvPOK_on (data); + SvPOK_only (data); if (dataoffset < 0) dataoffset += svlen; @@ -682,13 +686,18 @@ if (len < 0) croak ("length must not be negative"); + fd = PerlIO_fileno (ix == EIO_READ ? IoIFP (sv_2io (fh)) + : IoOFP (sv_2io (fh))); + + if (fd < 0) + croak ("illegal fh argument, either not an OS file or read/write mode mismatch"); + { dREQ; req->type = ix; req->sv1 = newSVsv (fh); - req->int1 = PerlIO_fileno (ix == EIO_READ ? IoIFP (sv_2io (fh)) - : IoOFP (sv_2io (fh))); + req->int1 = df; req->offs = SvOK (offset) ? SvVAL64 (offset) : -1; req->size = len; req->sv2 = SvREFCNT_inc (data);