Skip Menu |

This queue is for tickets about the ExtUtils-Typemaps-Default CPAN distribution.

Report information
The Basics
Id: 94110
Status: resolved
Priority: 0/
Queue: ExtUtils-Typemaps-Default

People
Owner: Nobody in particular
Requestors: aar [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



Subject: Typemap for std::string should not use SvCUR()
Hello, the current typemap for std::string does this: $var = std::string( SvPV_nolen( $arg ), SvCUR( $arg ) ); However, SvCUR() gets called before SvPV_nolen() but it does not guarantee the PV value is updated before computing length. See the following test case: ====== use Devel::Peek qw(Dump); use Inline C => (); my $value = '0.1'; $value = 2; Dump($value); foo($value); __END__ __C__ void foo (SV* var) { printf("Got %s with length = %zu\n", SvPV_nolen(var), SvCUR(var)); } // expected output: Got 2 with length = 1 // actual output: Got 2 with length = 3 <- WRONG! ====== So, something like this should be used in order to ensure std::string() is constructed using the right length. T_STD_STRING_PTR size_t len; const char * c = SvPV($arg, len); $var = new std::string(c, len);
I committed a bugfix for this. I'd appreciate a release when you have some time ;) Thank you!