More GetFieldIndex cases in ogr.i (was Re: [Gdal-dev] Perl interface now in Geo:: namespace by default)

Ari Jolma ari.jolma at
Sun Nov 19 13:50:10 EST 2006

I wrote:
> I also fixed a bug in the bindings, which made SetField(field_name, 
> value) silently fail even in a case where field with field_name did 
> not exist. Now it calls CPLError, which can be propagated upstream.
Seems that there were many more of these. I added to all of them checks 
and CPLError calls in case of not passing the check for non-nullness of 
the field name and for the validity of the field name.

This prevents countless seg faults and silent failures at least in Perl. 
Seg faults, because it is easy to feed an undef by accident to Perl 
subs, and swig translates these to NULL char pointers, which are poison 
to OGR's GetFieldIndex.

I also renamed GetFieldAsString to GetField in Perl bindings since it 
makes no sense to have typed methods in a typeless language.


More information about the Gdal-dev mailing list