develooper Front page | perl.perl5.porters | Postings from May 2010

[PATCH] Naif calls segfault T_PRTOBJ of the stock typemap

Thread Next
From:
Salvador Ortiz Garcia
Date:
May 27, 2010 09:23
Subject:
[PATCH] Naif calls segfault T_PRTOBJ of the stock typemap
Message ID:
4BFE9C8D.1030205@msg.com.mx
Hi,

$ perl -MPOSIX -e 'POSIX::Termios->getattr()'
Segmentation fault (core dumped)

$ perl -MGDBM_File -e 'GDBM_File->FETCH(1)'
Segmentation fault (core dumped)

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.

That typemap is used a little in core but in tons  in CPAN.

The following fixes it:

--- ExtUtils/typemap    2010-01-18 12:43:46.000000000 -0600
+++ ExtUtils/typemap.new    2010-05-27 11:03:18.138328347 -0500
@@ -149,7 +149,7 @@
              ${$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);
      }

Regards.

Salvador Ortiz.


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About