Skip to content

Commit

Permalink
Free expression tokens, which may store an index to an iteminfo, when…
Browse files Browse the repository at this point in the history
… iteminfo is freed. (#5161)
  • Loading branch information
mkofahl authored and tbonfort committed Dec 5, 2016
1 parent 14ce312 commit 7413952
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
29 changes: 22 additions & 7 deletions maplayer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand All @@ -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));
Expand All @@ -439,11 +459,6 @@ void msLayerClose(layerObj *layer)
msFreeExpressionTokens(&(layer->class[i]->labels[k]->text));
}
}

if (layer->vtable) {
layer->vtable->LayerClose(layer);
}
msLayerRestoreFromScaletokens(layer);
}

/*
Expand Down
1 change: 1 addition & 0 deletions mapserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7413952

Please sign in to comment.