From: Marcus Holland-Moritz Date: Fri, 1 Aug 2003 13:12:14 +0000 (+0200) Subject: Re: [perl #23185] perl crash with File::Glob X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e0e8a4dc9991fe9a8553e925ddf6f3ae1363478f;p=p5sagit%2Fp5-mst-13.2.git Re: [perl #23185] perl crash with File::Glob From: "Marcus Holland-Moritz" Message-ID: <00dc01c3581d$c3412c30$0c2f1fac@R2D2> p4raw-id: //depot/perl@20445 --- diff --git a/ext/File/Glob/Glob.pm b/ext/File/Glob/Glob.pm index a704b56..d670b6a 100644 --- a/ext/File/Glob/Glob.pm +++ b/ext/File/Glob/Glob.pm @@ -125,6 +125,7 @@ sub bsd_glob { # File::Glob::glob() is deprecated because its prototype is different from # CORE::glob() (use bsd_glob() instead) sub glob { + splice @_, 1; # don't pass PL_glob_index as flags! goto &bsd_glob; } diff --git a/ext/File/Glob/bsd_glob.c b/ext/File/Glob/bsd_glob.c index 83d71f0..c01e75a 100644 --- a/ext/File/Glob/bsd_glob.c +++ b/ext/File/Glob/bsd_glob.c @@ -261,12 +261,19 @@ bsd_glob(const char *pattern, int flags, #ifndef MACOS_TRADITIONAL patnext = (U8 *) pattern; #endif + /* TODO: GLOB_APPEND / GLOB_DOOFFS aren't supported yet */ +#if 0 if (!(flags & GLOB_APPEND)) { pglob->gl_pathc = 0; pglob->gl_pathv = NULL; if (!(flags & GLOB_DOOFFS)) pglob->gl_offs = 0; } +#else + pglob->gl_pathc = 0; + pglob->gl_pathv = NULL; + pglob->gl_offs = 0; +#endif pglob->gl_flags = flags & ~GLOB_MAGCHAR; pglob->gl_errfunc = errfunc; pglob->gl_matchc = 0; diff --git a/ext/File/Glob/t/basic.t b/ext/File/Glob/t/basic.t index 91f7913..00bd7406 100755 --- a/ext/File/Glob/t/basic.t +++ b/ext/File/Glob/t/basic.t @@ -13,7 +13,7 @@ BEGIN { print "1..0\n"; exit 0; } - print "1..11\n"; + print "1..12\n"; } END { print "not ok 1\n" unless $loaded; @@ -182,3 +182,7 @@ print $ok ? "ok 11\n" : "not ok 11\n"; unlink @f_names; chdir ".."; rmdir "pteerslo"; + +# this can panic if PL_glob_index gets passed as flags to bsd_glob +<*>; <*>; +print "ok 12\n";