[gdal-dev] Access violation OGRSpatialReference.importFromESRI() in GDAL304.dll
Paul Meems
bontepaarden at gmail.com
Fri Feb 4 07:47:22 PST 2022
Hi List,
We use GDAL v3+ in our Open Source mapping application MapWinGIS.
We build using VS2019 on Windows and we use the files from GisInternals.
We have a GeoProjection class which in turn calls
some/most OGRSpatialReference methods.
When calling OGRSpatialReference.importFromESRI() compiled for Win32 we
have no issues.
When calling the same code compiled for Win64 we get this exception:
Exception thrown at 0x00007FFD93074839 (gdal304.dll) 0xC0000005: Access
violation reading location 0xFFFFFFFFFFFFFFFF
We also implement the very similar method importFromWkt(). This method has
no issues on Win32 or Win64.
Here's some relevant code from GeoProjection.cpp:
STDMETHODIMP CGeoProjection::ImportFromESRI(const BSTR proj, VARIANT_BOOL*
retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
USES_CONVERSION;
const CString s = OLE2A(proj);
const OGRErr err = ProjectionHelper::ImportFromEsri(_projection, s);
*retVal = err == OGRERR_NONE ? VARIANT_TRUE : VARIANT_FALSE;
if (err != OGRERR_NONE)
{
ReportOgrError(err);
}
return S_OK;
}
STDMETHODIMP CGeoProjection::ImportFromWKT(const BSTR proj, VARIANT_BOOL*
retVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
USES_CONVERSION;
const CString s = OLE2A(proj);
const OGRErr err = ProjectionHelper::ImportFromWkt(_projection, s);
*retVal = err == OGRERR_NONE ? VARIANT_TRUE : VARIANT_FALSE;
if (err != OGRERR_NONE)
{
ReportOgrError(err);
}
return S_OK;
}
And from ProjectionHelper.cpp:
OGRErr ProjectionHelper::ImportFromEsri(OGRSpatialReference* sr, CString
proj)
{
if (!sr) {
return false;
}
char* s = proj.GetBuffer();
return sr->importFromESRI(&s);
}
OGRErr ProjectionHelper::ImportFromWkt(OGRSpatialReference* sr, CString
proj)
{
if (!sr) {
return false;
}
char* s = proj.GetBuffer();
return sr->importFromWkt(&s);
}
We're currently upgrading from GDAL2+ to GDAL3+.
Users report the crash in both versions.
Most likely we're not calling the importFromESRI correctly.
Please advice.
Regards,
Paul Meems
https://github.com/MapWindow/MapWinGIS
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20220204/c9476088/attachment.html>
More information about the gdal-dev
mailing list