Opened 17 years ago
Closed 17 years ago
#1718 closed defect (fixed)
OSR ExportToProj4 causes a setfault with an empty reference
Reported by: | hobu | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | 1.4.3 |
Component: | OGR_SRS | Version: | svn-trunk |
Severity: | normal | Keywords: | proj4 |
Cc: | Mateusz Łoskot |
Description (last modified by )
import osr ref = osr.SpatialReference() # download some junk ref.SetFromUserInput('http://spatialreference.org/user/6') # no problem here print ref.ExportToWkt() # goes splat here print ref.ExportToProj4()
0x024f48b9 in OGR_SRSNode::GetValue (this=0x0) at /Users/hobu/svn/gdal/ogr/ogr_spatialref.h:90 90 const char *GetValue() const { return pszValue; } (gdb) bt #0 0x024f48b9 in OGR_SRSNode::GetValue (this=0x0) at /Users/hobu/svn/gdal/ogr/ogr_spatialref.h:90 #1 0x0236d764 in OGRSpatialReference::exportToProj4 (this=0x30b870, ppszProj4=0xbffff518) at ogr_srs_proj4.cpp:957 #2 0x023730e1 in OSRExportToProj4 (hSRS=0x30b870, ppszReturn=0xbffff518) at ogr_srs_proj4.cpp:919 #3 0x0020c324 in _wrap_SpatialReference_ExportToProj4 (args=0x79f50) at osr_wrap.cpp:3271 #4 0x97eb67fe in PyObject_Call () #5 0x97f07450 in _PyEval_SliceIndex () #6 0x97f08a98 in PyEval_EvalCodeEx () #7 0x97f06f6d in _PyEval_SliceIndex () #8 0x97f08a98 in PyEval_EvalCodeEx () #9 0x97f08bbb in PyEval_EvalCode () #10 0x97f21dc5 in PyErr_Display () #11 0x97f2395a in PyRun_SimpleFileExFlags () #12 0x97f2b42b in Py_Main () #13 0x00001f8e in start () Current language: auto; currently c++
Change History (10)
comment:1 by , 17 years ago
Description: | modified (diff) |
---|
comment:2 by , 17 years ago
Component: | default → OGR_SRS |
---|---|
Keywords: | proj4 added |
Milestone: | 1.5.0 → 1.4.3 |
Resolution: | → fixed |
Status: | new → closed |
Version: | unspecified → 1.4.0 |
comment:3 by , 17 years ago
The old Python bindings still throw segmentation fault. The problem is in gdal_wrap.c:2388, OGRFree(wkt) is called for data allocated on stack (wkt = "").
Here is possible fix: {{[ err = OSRExportToProj4( _arg0, &wkt ); if( wkt == NULL ) {
ret = Py_BuildValue( "s", wkt ); OGRFree( wkt );
} else {
ret = Py_BuildValue( "s", "" );
} }}}
comment:4 by , 17 years ago
Cc: | added |
---|
comment:5 by , 17 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
comment:6 by , 17 years ago
Owner: | changed from | to
---|---|
Status: | reopened → new |
Taking this bug to apply termporary fix to gdal.i.
comment:7 by , 17 years ago
Status: | new → assigned |
---|
comment:8 by , 17 years ago
Owner: | changed from | to
---|---|
Status: | assigned → new |
Reassigned back to Frank to regenerate the gdal_wrap.c file.
comment:9 by , 17 years ago
Version: | 1.4.0 → svn-trunk |
---|
comment:10 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
gdal_wrap.c regenerated with SWIG 1.1pl5. I also updated the GNUmakefile to use the command name swig11pl5 to emphasize the version required.
The problem was introduced in 1.4.0 with the EXTENSION[] mechanism. I have corrected it in 1.4 and trunk branches.
Also added an error catch for unrecognised projection strings in trunk.
Also added tests for these cases in gdalautotest/osr/osr_proj4.py.