From: Florian Ragwitz Date: Tue, 10 Mar 2009 00:13:35 +0000 (+0100) Subject: Stop segfaulting when trying to get the name from a sub that's still being compiled. X-Git-Tag: 0.78_01~76 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a7c816fa444a35b0e528df2b065019a02c4ccd51;p=gitmo%2FClass-MOP.git Stop segfaulting when trying to get the name from a sub that's still being compiled. --- diff --git a/MOP.xs b/MOP.xs index 7d82305..c86a013 100644 --- a/MOP.xs +++ b/MOP.xs @@ -120,6 +120,12 @@ get_code_info (SV *coderef, char **pkg, char **name) } coderef = SvRV(coderef); + + /* sub is still being compiled */ + if (!CvGV(coderef)) { + return 0; + } + /* 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)