Changeset 12543

Show
Ignore:
Timestamp:
10/26/07 14:43:47 (10 months ago)
Author:
mloskot
Message:

Fixed memory allocation error during SPATIAL INDEX creation for Shapefile (Ticket #1594).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/gdal/ogr/ogrsf_frmts/shape/shapefil.h

    r12110 r12543  
    312312#define MAX_SUBNODE     4 
    313313 
     314/* upper limit of tree levels for automatic estimation */ 
     315#define MAX_DEFAULT_TREE_DEPTH 12 
     316 
    314317typedef struct shape_tree_node 
    315318{ 
  • trunk/gdal/ogr/ogrsf_frmts/shape/shptree.c

    r12540 r12543  
    195195            psTree->nMaxDepth += 1; 
    196196            nMaxNodeCount = nMaxNodeCount * 2; 
     197        } 
     198 
     199        /* NOTE: Due to problems with memory allocation for deep trees, 
     200         * automatically estimated depth is limited up to 12 levels. 
     201         * See Ticket #1594 for detailed discussion. 
     202         */ 
     203        if( psTree->nMaxDepth > MAX_DEFAULT_TREE_DEPTH ) 
     204        { 
     205            psTree->nMaxDepth = MAX_DEFAULT_TREE_DEPTH; 
     206 
     207#ifdef USE_CPL 
     208        CPLDebug( "Shape", 
     209                  "Falling back to max number of allowed index tree levels (%d).", 
     210                  MAX_DEFAULT_TREE_DEPTH ); 
     211#endif 
    197212        } 
    198213    }