Opened 20 years ago

Closed 15 years ago

#615 closed defect (fixed)

infinite recursive call when GetNextFeature from a empty mitab file with a filter.

Reported by: clear@… Owned by: warmerdam
Priority: high Milestone:
Component: OGR_SF Version: unspecified
Severity: normal Keywords:
Cc:

Description

I have a empty MapInfo TAB file, there is no feature in it.
When I use SetSpatialFilter set a filter for it, GetNextFeature output many
error message like this:

ERROR 3: InitBlockFromData(): Invalid Block Type: got 0 expected 2
ERROR 1: ReadBytes(): Attempt to read past end of data block.
ERROR 1: ReadBytes(): Attempt to read past end of data block.
ERROR 1: ReadBytes(): Attempt to read past end of data block.
...

There is an error in file ogr/ogrsf_frmts/mitab/mitab_mapfile.cpp, this is patch:

Index: ogr/ogrsf_frmts/mitab/mitab_mapfile.cpp
===================================================================
RCS file: /cvs/maptools/cvsroot/gdal/ogr/ogrsf_frmts/mitab/mitab_mapfile.cpp,v
retrieving revision 1.18
diff -u -r1.18 mitab_mapfile.cpp
--- ogr/ogrsf_frmts/mitab/mitab_mapfile.cpp     7 Jul 2004 20:54:55 -0000       1.18
+++ ogr/ogrsf_frmts/mitab/mitab_mapfile.cpp     22 Sep 2004 03:52:26 -0000
@@ -560,7 +560,7 @@
         CPLAssert( m_poSpIndex == NULL && m_poSpIndexLeaf == NULL );
 
         if( PushBlock( m_poHeader->m_nFirstIndexBlock ) == NULL )
-            return -1;
+            return FALSE;
 
         if( m_poSpIndex == NULL )
         {



This patch can avoid infinite recursion, but still an error message remained.

Attachments (1)

gdal.test.zip (1.0 KB ) - added by clear@… 20 years ago.
empty MapInfo TAB file

Download all attachments as: .zip

Change History (6)

comment:1 by warmerdam, 20 years ago

I have committed your change, it is clearly an improvement. 

Could you attached a dataset (in a zip file perhaps) demonstrating the
error report?  

by clear@…, 20 years ago

Attachment: gdal.test.zip added

empty MapInfo TAB file

comment:2 by clear@…, 20 years ago

I have uploaded a attach file:
http://208.24.120.44/showattachment.cgi?attach_id=153

with this dataset, the following command line will cause error message:

$ ogrinfo -spat 116.425737 39.901000 116.457880 39.915702  ±±¾©_Çø»®ÂÖÀª.TAB ±±
¾©_Çø»®ÂÖÀª

comment:3 by warmerdam, 20 years ago

confirmed error ...



warmerda@gdal2200[55]% ogrinfo -al -spat 116.425737 39.901000 116.457880
39.915702 ����_�����.TAB
Had to open data source read-only.
INFO: Open of `����_�����.TAB'
using driver `MapInfo File' successful.

Layer name: ����_�����
Geometry: Unknown (any)
ERROR 3: InitBlockFromData(): Invalid Block Type: got 0 expected 2
Feature Count: 0
Extent: (-0.000000, 0.000000) - (-0.000000, 0.000000)
Layer SRS WKT:
GEOGCS["unnamed",
    DATUM["MIF 0",
        SPHEROID["WGS 84 (MAPINFO Datum 0)",6378137.01,298.257223563],
        TOWGS84[0,0,0,-0,-0,-0,0]],
    PRIMEM["Greenwich",0],
    UNIT["degree",0.0174532925199433]]
���: String (60.0)
ERROR 3: InitBlockFromData(): Invalid Block Type: got 0 expected 2

comment:4 by warmerdam, 20 years ago

As far as I know there aren't any features in this file, so the issue is to
avoid returning a spurios error message.  I don't have time to dig into this
just now, so I am going to set it aside for later.  I will also add Daniel to
the cc: list in case he would like to tackle it.  It is really in the core
MITAB code which he knows much better than I do.


comment:5 by Even Rouault, 15 years ago

Resolution: fixed
Status: assignedclosed

This was fixed a long time ago : http://trac.osgeo.org/gdal/changeset/6563

Note: See TracTickets for help on using tickets.