[Gdal-dev] Assertion in .tab driver

Daniel Morissette dmorissette at mapgears.com
Thu Jun 14 14:49:31 EDT 2007


I've received a contributed patch recently to replace this same 
isspace() call with a call to iswspace(), claiming that isspace() could 
potentially "crash" when passed a wide char. The change is not in GDAL 
yet, it will be ported to the GDAL copy of the MITAB driver before the 
GDAL 1.5.0 release.

I wonder if his "crash" might have been the same assert that you 
encountered and if yes then which fix between yours and his is better. I 
have contacted him to get his thoughts but haven't received any reply 
yet. I'd welcome your comments too.

Daniel



Daniel wrote:
> Hello,
> 
> If you build GDAL against the debug version of the c-runtime with
> Visual Studio 2005 (/MDd) and try to open a .tab file with 8-bit ASCII
> characters in it, the field names for instance, you get an assert in
> isspace on row 177 in
> http://trac.osgeo.org/gdal/browser/trunk/gdal/ogr/ogrsf_frmts/mitab/mitab_imapinfofile.cpp 
> 
> 
> The parameter passed to isspace is a signed char which is converted to
> a signed int so any values >127 will become negative. It seems to work
> fine when built against the release libraries and if you ignore the
> assert it seems to work so this is probably nothing serious maybe
> depending on the locale that is used. It can easily be fixed by
> casting the char to an unsigend char before passing it to isspace:
> isspace((unsigned char)*pszLine)
> 
> Regards,
>  Daniel Bäck
> 
> _______________________________________________
> Gdal-dev mailing list
> Gdal-dev at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/gdal-dev


-- 
Daniel Morissette
http://www.mapgears.com/



More information about the Gdal-dev mailing list