Naif calls segfault T_PRTOBJ of the stock typemap
Salvador Ortiz Garcia [Fri, 28 May 2010 08:25:52 +0000 (10:25 +0200)]
The T_PTROBJ INPUT in stock typemap only uses 'sv_derived_from' for
input validation, that cause a segfault when the argument passed match
the class name.

lib/ExtUtils/typemap

index 2c35437..f888587 100644 (file)
@@ -149,7 +149,7 @@ T_REF_IV_PTR
                        ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
                        \"$var\", \"$ntype\")
 T_PTROBJ
-       if (sv_derived_from($arg, \"${ntype}\")) {
+       if (SvROK($arg) && sv_derived_from($arg, \"${ntype}\")) {
            IV tmp = SvIV((SV*)SvRV($arg));
            $var = INT2PTR($type,tmp);
        }