Opened 11 years ago

Last modified 11 years ago

#5045 closed defect

A crash about using gdal dll when create a Polygon using new Polygon — at Initial Version

Reported by: cpponly2008 Owned by: warmerdam
Priority: normal Milestone:
Component: default Version: unspecified
Severity: normal Keywords:
Cc:

Description

I try to create a polygon geometry by using gdal module int the following code in my workspace, but it is crashed when I debug the program, and it runs well in non-debug status.

void testCreatePolygon()
{
	//this function is crashed when debugging in my own project
	OGRPolygon *oPolygon1 = new OGRPolygon;
	OGRPoint op1(0.0, 0.0);
	OGRPoint op2(0.0, 1.0);
	OGRPoint op3(1.0, 1.0);
	OGRPoint op4(1.0, 0.0);
	OGRPoint op5(0.0, 0.0);
	OGRLinearRing oLR1;
	oLR1.addPoint(&op1);
	oLR1.addPoint(&op2);
	oLR1.addPoint(&op3);
	oLR1.addPoint(&op4);
	oLR1.addPoint(&op5);
	oPolygon1->addRingDirectly(&oLR1);
	delete oPolygon1;
}

The error point to the following gdal source code:

void OGRPolygon::empty()

{
    if( papoRings != NULL )
    {
        for( int i = 0; i < nRingCount; i++ )
        {
            delete papoRings[i];//this crash
        }
        OGRFree( papoRings );
    }

    papoRings = NULL;
    nRingCount = 0;
}

Then I look up the source code in the gdal module, there is the same code as I do. I debug the code, it isn't crashed. So I consider there is something wrong when cross-gdal dll calling.

Change History (0)

Note: See TracTickets for help on using tickets.