From: Steve Peters Date: Tue, 3 Jan 2006 18:14:27 +0000 (+0000) Subject: Attemting to readdir() something that isn't a dirhandle should cause X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3b7fbd4a8e0aec57c7898a1775b0a17a345883de;p=p5sagit%2Fp5-mst-13.2.git Attemting to readdir() something that isn't a dirhandle should cause a warning. p4raw-id: //depot/perl@26617 --- diff --git a/pod/perldiag.pod b/pod/perldiag.pod index 54b42eb..6b3ba31 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -3353,6 +3353,11 @@ are outside the range which can be represented by integers internally. One possible workaround is to force Perl to use magical string increment by prepending "0" to your numbers. +=item readdir() attempted on invalid dirhandle %s + +(W io) The dirhandle you're reading from is either closed or not really +a dirhandle. Check your control flow. + =item readline() on closed filehandle %s (W closed) The filehandle you're reading from got itself closed sometime diff --git a/pp_sys.c b/pp_sys.c index ab14c67..6a4b34c 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -3689,8 +3689,13 @@ PP(pp_readdir) register const Direntry_t *dp; register IO * const io = GvIOn(gv); - if (!io || !IoDIRP(io)) - goto nope; + if (!io || !IoDIRP(io)) { + if(ckWARN(WARN_IO)) { + Perl_warner(aTHX_ packWARN(WARN_IO), + "readdir() attempted on invalid dirhandle %s", GvENAME(gv)); + } + goto nope; + } do { dp = (Direntry_t *)PerlDir_read(IoDIRP(io));