Opened 16 years ago

Closed 16 years ago

#468 closed defect (fixed)

crash in GPJ_grass_to_wkt() on windows

Reported by: jef Owned by: grass-dev@…
Priority: major Milestone: 6.4.0
Component: Default Version: unspecified
Keywords: Cc:
CPU: Unspecified Platform: MSWindows XP

Description

QGIS crashes when calling GPJ_grass_to_wkt(), when the MinGW built libraries are called from MSVC build QGIS. This is caused to using G_free() on a string alloced in proj.4 with pj_malloc(). The attached patch free the string with pj_dalloc()

Attachments (1)

patch_for_468.diff (361 bytes ) - added by jef 16 years ago.
patch to fix #468

Download all attachments as: .zip

Change History (6)

by jef, 16 years ago

Attachment: patch_for_468.diff added

patch to fix #468

comment:1 by neteler, 16 years ago

The definition of pj_dalloc() is here: http://svn.osgeo.org/metacrs/proj/trunk/proj/src/pj_malloc.c

void
pj_dalloc(void *ptr) {
	free(ptr);
}

The definition of G_free() is here: http://trac.osgeo.org/grass/browser/grass/branches/develbranch_6/lib/gis/alloc.c#L127

void G_free(void *buf)
{
    free(buf);
}

Is there a difference?

in reply to:  1 ; comment:2 by jef, 16 years ago

Replying to neteler:

The definition of pj_dalloc() is here: http://svn.osgeo.org/metacrs/proj/trunk/proj/src/pj_malloc.c

void
pj_dalloc(void *ptr) {
	free(ptr);
}

The definition of G_free() is here: http://trac.osgeo.org/grass/browser/grass/branches/develbranch_6/lib/gis/alloc.c#L127

void G_free(void *buf)
{
    free(buf);
}

Is there a difference?

sure. Every DLL runs it own memory management and therefore memory malloc() in a one DLL needs to be free by the very same DLL and that's probably the sole reason for the existance of above functions (same for GDAL, GEOS...).

in reply to:  2 comment:3 by jef, 16 years ago

Replying to jef:

sure. Every DLL runs it own memory management and therefore memory malloc() in a one DLL needs to be free by the very same DLL and that's probably the sole reason for the existance of above functions (same for GDAL, GEOS...).

Did you also have a dejavu? ;) http://trac.osgeo.org/gdal/ticket/1983

comment:4 by pkelly, 16 years ago

I fixed this in TRUNK, and fixed a few memory leaks at the same time. The changes are too complicated/risky to backport to 6.x though, so the simple patch attached here should be OK for a quick fix.

comment:5 by neteler, 16 years ago

Resolution: fixed
Status: newclosed

jef's patch applied to 6.4.svn (r35668) and 6.4.0svn (r35669).

Note: See TracTickets for help on using tickets.