[Gdal-dev] segfault in SHPCreateObject

Ari Jolma ari.jolma at tkk.fi
Tue Sep 13 01:41:43 EDT 2005


Back to this.. there were a couple of things which were sorted out in 
IRC yesterday, there is the fact that it segfaulted, which is a policy 
issue perhaps, the policy could be "one should not be able to produce a 
seg fault by a scripting interface". Does that sound reasonable?

The issue here is that if a crippled polygon (into which no ring has 
been put, i.e. the $g->AddGeometry($r); is missing from below -- as it 
was because it silently failed) is given to SHPWriteOGRObject it seg 
faults. This is because it uses getNumInteriorRings()+1 as the nRings, 
thus implicitly assuming ExteriorRing exists. SHPWriteOGRObject could 
also return "corrupt data" in this case.

Ari

Ari Jolma kirjoitti:

> Any ideas why this segfaults:
>
> my $fd = new ogr::FeatureDefn;
> my $f = new ogr::Feature($fd);
> my $g = new ogr::Geometry($ogr::wkbPolygon);
> my $r = new ogr::Geometry($ogr::wkbLinearRing);
> do this many times:        $r->AddPoint($lon,$lat);
> $g->AddGeometry($r);
> $g->CloseRings;
> $f->SetGeometry($g);
> $layer->CreateFeature($f);
>
> layer should be ok, I probably need something more into those new's?
>
> Ari
>


-- 
Prof. Ari Jolma
Kartografia ja Geoinformatiikka / Cartography and Geoinformatics
Teknillinen Korkeakoulu / Helsinki University of Technology
POBox 1200, 02015 TKK, Finland
Email: ari.jolma at tkk.fi URL: http://www.tkk.fi/~jolma




More information about the Gdal-dev mailing list