In some situations, attribute bindings may cause a segmentation fault, when executing multiple MapScript operations, e.g. queryByPoint() followed by draw() on the same layer. This is because the expression is tokenized only once - when uninitialized. In case of an attribute binding, the token bindval index points to the sql column-index built from the list of required attributes, in case of queryByPoint() all attributes are requested. A possibly following draw() will reduce the number of attributes to be queried from the database, so the column index in the resultset changes, but the expression token is still the same.
The fix is to free the expression object, when msLayerFreeItemInfo() is called, which is currently done at LayerClose() only.
Free expression tokens, which may store an index to an iteminfo, when…
… iteminfo is freed. (#5161)
@tbonfort Looks good to me now.
@sdlime can you please check this is OK for 7.0.1 ?
Thomas: Missed this one. Ok to include IMHO... --Steve
Applied to branch-7-0 in 7413952