Leak of shapefile handles
We have found that mapshape.c can leak file handles when using tileindexes on
shapefile layers.
This leak is very hard to reproduce, it happens only when rendering a map on a
tiled shapefile layer in which some tiles match the current map extents, but the
actual shapefile for that given tile does not contain any shape in the current
map extent, this can happen when hitting the corner of a tile for instance.
What happens is that msTiledSHPWhichShapes() has a loop to "position the source
at the FIRST shapefile" that tries to open tiles until it reaches one that
contains visible shapes. If the call to msSHPWhichShapes() for a given tile
returns MS_DONE, then we were just continuing the loop without closing the open
file, resulting in a leaked file handle (leaks of all three shp, shx and dbf
handles).
The fix is simple:
--- mapshape.c 15 May 2006 19:11:29 -0000 1.69.2.1
+++ mapshape.c 14 Jun 2006 12:26:23 -0000
@@ -1732,7 +1732,11 @@
#endif
status = msSHPWhichShapes(tSHP->shpfile, rect, layer->debug);
- if(status == MS_DONE) continue; /* next tile */
+ if(status == MS_DONE) {
+ /* Close and continue to next tile */
+ msSHPCloseFile(tSHP->shpfile);
+ continue;
+ }
else if(status != MS_SUCCESS) return(MS_FAILURE);
tSHP->tileshpfile->lastshape = i;
Change History
(3)
Resolution: |
→ fixed
|
Status: |
new → closed
|