PPCODE:
if( SvOK(coderef) && SvROK(coderef) && SvTYPE(SvRV(coderef)) == SVt_PVCV){
coderef = SvRV(coderef);
- name = GvNAME( CvGV(coderef) );
- pkg = HvNAME( GvSTASH(CvGV(coderef)) );
+ /* I think this only gets triggered with a mangled coderef, but if
+ we hit it without the guard, we segfault. The slightly odd return
+ value strikes me as an improvement (mst)
+ */
+ if (isGV_with_GP(CvGV(coderef))) {
+ pkg = HvNAME( GvSTASH(CvGV(coderef)) );
+ name = GvNAME( CvGV(coderef) );
+ } else {
+ pkg = "__UNKNOWN__";
+ name = "__ANON__";
+ }
EXTEND(SP, 2);
PUSHs(newSVpvn(pkg, strlen(pkg)));