develooper Front page | perl.perl5.porters | Postings from November 2011

Re: [perl #102586] version->new("version") SEGVs

Thread Previous
From:
John Peacock
Date:
November 12, 2011 05:16
Subject:
Re: [perl #102586] version->new("version") SEGVs
Message ID:
4EBE7192.8050807@havurah-software.org
On 11/03/2011 12:08 PM, David Golden wrote:
> On Mon, Oct 31, 2011 at 11:17 AM, Brian Fraser<fraserbn@gmail.com>  wrote:
>> There's a couple other uses of sv_derived_from that check for version
>> objects, like line 618 of universal.c. Should those get the added guards
>> too?
>
> Yes.
>
> Or maybe we need a "sv_obj_isa" function/macro to encapsulate the concept.

Sorry I took so long to respond to this.  Yes, I think sv_obj_isa would 
be the right way to go with this.  I actually added this to the CPAN 
version.pm distro:

#define ISA_VERSION_OBJ(v,c) (SvROK(v) && sv_derived_from(v,c))

though there is nothing about that define that is specific to version 
objects.

> Nicholas -- I believe the patch is correct enough, though a segfault
> is still possible if someone creates a bogus object and blesses it to
> 'version' or a subclass thereof.

There is already a vverify() routine, which should protect the vast 
majority of the possible problems with bogus objects.

John

Thread Previous


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