Permalink
Browse files

Free expression tokens, which may store an index to an iteminfo, when…

… iteminfo is freed. (#5161)
  • Loading branch information...
1 parent 14ce312 commit 7413952a17f826926066fa46dbc2c784117c5068 @mkofahl mkofahl committed with tbonfort Sep 30, 2015
Showing with 23 additions and 7 deletions.
  1. +22 −7 maplayer.c
  2. +1 −0 mapserver.h
View
@@ -65,6 +65,13 @@ void msLayerFreeItemInfo(layerObj *layer)
return;
}
layer->vtable->LayerFreeItemInfo(layer);
+
+ /*
+ * Layer expressions with attribute binding hold a numeric index pointing
+ * to an iteminfo (node->tokenval.bindval.index). If iteminfo changes,
+ * an expression may be no longer valid. (#5161)
+ */
+ msLayerFreeExpressions(layer);
}
int msLayerRestoreFromScaletokens(layerObj *layer)
@@ -415,8 +422,6 @@ int msLayerGetShape(layerObj *layer, shapeObj *shape, resultObj *record)
*/
void msLayerClose(layerObj *layer)
{
- int i,j,k;
-
/* no need for items once the layer is closed */
msLayerFreeItemInfo(layer);
if(layer->items) {
@@ -426,6 +431,21 @@ void msLayerClose(layerObj *layer)
}
/* clear out items used as part of expressions (bug #2702) -- what about the layer filter? */
+ msLayerFreeExpressions(layer);
+
+ if (layer->vtable) {
+ layer->vtable->LayerClose(layer);
+ }
+ msLayerRestoreFromScaletokens(layer);
+}
+
+/*
+** Clear out items used as part of expressions.
+*/
+void msLayerFreeExpressions(layerObj *layer)
+{
+ int i,j,k;
+
msFreeExpressionTokens(&(layer->filter));
msFreeExpressionTokens(&(layer->cluster.group));
msFreeExpressionTokens(&(layer->cluster.filter));
@@ -439,11 +459,6 @@ void msLayerClose(layerObj *layer)
msFreeExpressionTokens(&(layer->class[i]->labels[k]->text));
}
}
-
- if (layer->vtable) {
- layer->vtable->LayerClose(layer);
- }
- msLayerRestoreFromScaletokens(layer);
}
/*
View
@@ -2412,6 +2412,7 @@ void msPopulateTextSymbolForLabelAndString(textSymbolObj *ts, labelObj *l, char
MS_DLL_EXPORT int msClusterLayerOpen(layerObj *layer); /* in mapcluster.c */
MS_DLL_EXPORT int msLayerIsOpen(layerObj *layer);
MS_DLL_EXPORT void msLayerClose(layerObj *layer);
+ MS_DLL_EXPORT void msLayerFreeExpressions(layerObj *layer);
MS_DLL_EXPORT int msLayerWhichShapes(layerObj *layer, rectObj rect, int isQuery);
MS_DLL_EXPORT int msLayerGetItemIndex(layerObj *layer, char *item);
MS_DLL_EXPORT int msLayerWhichItems(layerObj *layer, int get_all, const char *metadata);

0 comments on commit 7413952

Please sign in to comment.