sometimes the stash doesn't exist at all attic/ignore-duplicate-role-application
Jesse Luehrs [Thu, 29 Mar 2012 07:50:35 +0000 (02:50 -0500)]
for instance, when it has been deleted

mop.c

diff --git a/mop.c b/mop.c
index 6cb77f0..23ca98a 100644 (file)
--- a/mop.c
+++ b/mop.c
@@ -95,12 +95,14 @@ mop_get_code_info (SV *coderef, char **pkg, char **name)
     */
 
     if ( isGV_with_GP(CvGV(coderef)) ) {
-        GV *gv   = CvGV(coderef);
-        *pkg     = HvNAME( GvSTASH(gv) ? GvSTASH(gv) : CvSTASH(coderef) );
-        *name    = GvNAME( CvGV(coderef) );
+        GV *gv    = CvGV(coderef);
+        HV *stash = GvSTASH(gv) ? GvSTASH(gv) : CvSTASH(coderef);
+
+        *pkg  = stash ? HvNAME(stash) : "__UNKNOWN__";
+        *name = GvNAME( CvGV(coderef) );
     } else {
-        *pkg     = "__UNKNOWN__";
-        *name    = "__ANON__";
+        *pkg  = "__UNKNOWN__";
+        *name = "__ANON__";
     }
 
     return 1;