[mapserver-dev] Memory Leak
Paul Ramsey
pramsey at cleverelephant.ca
Fri Oct 3 17:08:28 EDT 2008
Looks sane to me. Add a trac ticket (http://trac.osgeo.org/mapserver)
for it, attach the patch, and someone will commit it for you.
P.
On Fri, Oct 3, 2008 at 2:02 PM, Ned Harding <nharding at extendthereach.com> wrote:
> There is a memory leak in msInsertLayer. The below patch fixes it. Can
> someone else review it and tell me what I should do with it?
>
>
>
> Thanks,
>
>
>
> Ned.
>
>
>
> Index: S:/3rdParty/GIS/MapServer/mapobject.c
>
> ===================================================================
>
> --- S:/3rdParty/GIS/MapServer/mapobject.c (revision 15750)
>
> +++ S:/3rdParty/GIS/MapServer/mapobject.c (working copy)
>
> @@ -498,10 +498,20 @@
>
> }
>
>
>
> /* Ensure there is room for a new layer */
>
> - if (msGrowMapLayers(map) == NULL)
>
> - return -1;
>
> - /* Catch attempt to insert past end of layers array */
>
> - else if (nIndex >= map->numlayers) {
>
> + if (map->numlayers == map->maxlayers)
>
> + {
>
> + if (msGrowMapLayers(map) == NULL)
>
> + return -1;
>
> + }
>
> +
>
> + /* msGrowMapLayers allocates the new layer which we don't
> need to do since we have 1 that we are inserting
>
> + not sure if it is possible for this to be non
> null otherwise, but better to check since this function
>
> + replaces the value */
>
> + if (map->layers[map->numlayers]!=NULL)
>
> + free(map->layers[map->numlayers]);
>
> +
>
> + /* Catch attempt to insert past end of layers array */
>
> + if (nIndex >= map->numlayers) {
>
> msSetError(MS_CHILDERR, "Cannot insert layer beyond index %d",
>
> "msInsertLayer()", map->numlayers-1);
>
> return -1;
>
>
>
> _______________________________________________
> mapserver-dev mailing list
> mapserver-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-dev
>
>
More information about the mapserver-dev
mailing list