In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/432d4561c48cd74f3299eddc270a890908a4512e?hp=0db511c03fa45894d146905ba3408b3be3f5baa0>

- Log -----------------------------------------------------------------
commit 432d4561c48cd74f3299eddc270a890908a4512e
Author: Jesse Luehrs <[email protected]>
Date:   Mon Sep 24 00:29:06 2012 -0500

    don't crash with -d if DB::DB is seen but not defined [perl #114990]
-----------------------------------------------------------------------

Summary of changes:
 MANIFEST            |    1 +
 pp_ctl.c            |    5 ++++-
 t/lib/Devel/nodb.pm |    3 +++
 t/run/switchd.t     |   13 ++++++++++++-
 4 files changed, 20 insertions(+), 2 deletions(-)
 create mode 100644 t/lib/Devel/nodb.pm

diff --git a/MANIFEST b/MANIFEST
index a633ad5..93ce636 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -5074,6 +5074,7 @@ t/lib/dbmt_common.pl              Common functionality 
for ?DBM_File tests
 t/lib/deprecate/Deprecated.pm  Deprecated module to test deprecate.pm
 t/lib/deprecate/Optionally.pm  Optionally deprecated module to test 
deprecate.pm
 t/lib/deprecate.t              Test deprecate.pm
+t/lib/Devel/nodb.pm            Module for t/run/switchd.t
 t/lib/Devel/switchd_empty.pm   Module for t/run/switchd.t
 t/lib/Devel/switchd.pm         Module for t/run/switchd.t
 t/lib/feature/bundle           Tests for feature bundles
diff --git a/pp_ctl.c b/pp_ctl.c
index ce88220..e857ad4 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -1960,7 +1960,10 @@ PP(pp_dbstate)
        const I32 gimme = G_ARRAY;
        U8 hasargs;
        GV * const gv = PL_DBgv;
-       CV * const cv = GvCV(gv);
+       CV * cv = NULL;
+
+        if (gv && isGV_with_GP(gv))
+            cv = GvCV(gv);
 
        if (!cv)
            DIE(aTHX_ "No DB::DB routine defined");
diff --git a/t/lib/Devel/nodb.pm b/t/lib/Devel/nodb.pm
new file mode 100644
index 0000000..069380f
--- /dev/null
+++ b/t/lib/Devel/nodb.pm
@@ -0,0 +1,3 @@
+package Devel::nodb;
+*DB::DB = sub { } if 0;
+1;
diff --git a/t/run/switchd.t b/t/run/switchd.t
index eadcd94..1dffb2d 100644
--- a/t/run/switchd.t
+++ b/t/run/switchd.t
@@ -9,7 +9,7 @@ BEGIN { require "./test.pl"; }
 
 # This test depends on t/lib/Devel/switchd*.pm.
 
-plan(tests => 7);
+plan(tests => 8);
 
 my $r;
 
@@ -110,3 +110,14 @@ like(
   qr "ok\r?\n",
  'No crash when calling orphaned subroutine via goto &',
 );
+
+# test when DB::DB is seen but not defined [perl #114990]
+like(
+  runperl(
+    switches => [ '-Ilib', '-d:nodb' ],
+    prog     => [ '1' ],
+    stderr   => 1,
+  ),
+  qr/^No DB::DB routine defined/,
+  "No crash when DB::DB isn't actually defined",
+);

--
Perl5 Master Repository

Reply via email to