http://qs1969.pair.com?node_id=528436


in reply to Re^10: Segfault on second (identical) call to a sub
in thread Segfault on second (identical) call to a sub

I'm no expert on XS files either, which is why I usually let Inline::C handle that side of things ... but I don't think 'data' should be safefree()'d ... and I wish you had pointed it out sooner :-)

I got sidetracked into thinking that there must be something bodgey in the way the GD::Image objects were being created.

You could probably go a little further and not even declare and assign a value to 'data'. I think one could just as well write
RETVAL = (GD__Image) gdImageCreateFromGdPtr(len,(void*)SvPV(imageData, + len));
but that's only a minor point.
It's unclear to me how 'len' gets assigned the appropriate value for when it's needed ... but it seems to happen ok.

You should probably go to http://rt.cpan.org/Public/Dist/Display.html?Name=GD and report the bug there - or at least let the author know.

Well spotted !!

Cheers,
Rob