Ticket #697 (closed defect: fixed)
mapogr.cpp uses delete on GDAL allocated objects
| Reported by: | warmerdam | Owned by: | mapserverbugs |
|---|---|---|---|
| Priority: | high | Milestone: | 5.2 release |
| Component: | OGR Support | Version: | 4.3 |
| Severity: | normal | Keywords: | |
| Cc: |
Description (last modified by hobu) (diff)
Mladen Turk wrote:
> Hi all,
>
> There is a memory leak in mapogr.cpp.
>
> The reason is quite simple and obvious when using gdal as dll, and it
> involves operator delete on a memory that has been allocated using
> OGRSFDriverRegistrar::Open in a gdal dll, that has a different memory heap.
>
> Not sure how to resolve this, but something like
>
> void GDALDelete(void *p)
> {
> delete p;
> }
>
> Inside the gdal itself should be called instead simply calling delete from
> mapserver or mapscript.
Mladen,
In fact, this is generally worse than just a memory leak ... it is a heap
corruption. Can you point out the particular places this is occuring? Skimming
the mapogr.cpp I can see a number of questionable uses of delete likely to
cause problems.
There are "destructor" methods for most types in OGR. For instance,
the OGRFeature::DestroyFeature( poFeature ) static method can be used to
destroy features within the GDAL DLL itself.
Attachments
Change History
Note: See
TracTickets for help on using
tickets.

