[Gdal-dev] Use of assert() on troublesome files

Chapman, Martin MChapman at sanz.com
Fri Mar 5 00:51:08 EST 2004


Ben,

I was able to open this file using GDAL fine.  What problem were you
having?

Martin

-----Original Message-----
From: Ben Discoe [mailto:ben at vterrain.org] 
Sent: Thursday, March 04, 2004 8:01 PM
To: gdal-dev at remotesensing.org
Subject: [Gdal-dev] Use of assert() on troublesome files



This evening i was trying to read a TIF file from a data agency, here:

ftp://keone.soest.hawaii.edu/pub/coastal_ftp/Imagery/Oahu/GeoTiffs/kaena
pt.z
ip

It crashes GDAL (assert failure) down inside the TIF code.  This got me
thinking, why do we use assert() this way in GDAL?  It effectively
crashes the calling app, which then has no way to inform the user of the
problem or continue gracefully.

It was fixable by changing the assert:

fmts/gtiff/libtiff.c, line 606
< 	assert(sp->cinfo.comm.is_decompressor);
----
> 	if (sp->cinfo.comm.is_decompressor == 0) {
>		TIFFError("JPEGSetupDecode", "JPEG is not
decompressor");
>		return (0);
>	}

1. Perhaps there is some way to trap these assert() failures in an app
calling GDAL? 2. Perhaps assert() should be used only to detect cases of
a logical flaw in the code, rather than unexpected input data?

Thanks,
Ben

_______________________________________________
Gdal-dev mailing list
Gdal-dev at remotesensing.org
http://remotesensing.org/mailman/listinfo/gdal-dev



More information about the Gdal-dev mailing list