Skip to content
Permalink
Browse files

Return value of setlocale() is allocated in static storage and is thu…

…s volatile.

This commit fixes the following Valgrind error :
==17204== Invalid read of size 1
==17204==    at 0x4C29F34: __GI_strchr (mc_replace_strmem.c:219)
==17204==    by 0xBF5E14C: _nl_load_locale_from_archive (loadarchive.c:170)
==17204==    by 0xBF5D60A: _nl_find_locale (findlocale.c:107)
==17204==    by 0xBF5CB8B: setlocale (setlocale.c:379)
==17204==    by 0x808B776: QgsCoordinateReferenceSystem::setProj4String(QString) (in /home/even/qgis-git/Quantum-GIS/build/install/lib/libqgis_core.so.1.9.0)
==17204==    by 0x808A401: QgsCoordinateReferenceSystem::createFromProj4(QString) (in /home/even/qgis-git/Quantum-GIS/build/install/lib/libqgis_core.so.1.9.0)
==17204==    by 0x7FC2F68: QgsDistanceArea::setEllipsoid(QString const&) (in /home/even/qgis-git/Quantum-GIS/build/install/lib/libqgis_core.so.1.9.0)
==17204==    by 0x6D23A3: QgsMeasureDialog::updateSettings() (in /home/even/qgis-git/Quantum-GIS/build/install/bin/qgis)
==17204==    by 0x6D200D: QgsMeasureDialog::QgsMeasureDialog(QgsMeasureTool*, QFlags<Qt::WindowType>) (in /home/even/qgis-git/Quantum-GIS/build/install/bin/qgis)
==17204==    by 0x6D5777: QgsMeasureTool::QgsMeasureTool(QgsMapCanvas*, bool) (in /home/even/qgis-git/Quantum-GIS/build/install/bin/qgis)
==17204==    by 0x553E4B: QgisApp::createCanvasTools() (in /home/even/qgis-git/Quantum-GIS/build/install/bin/qgis)
==17204==    by 0x544411: QgisApp::QgisApp(QSplashScreen*, bool, QWidget*, QFlags<Qt::WindowType>) (in /home/even/qgis-git/Quantum-GIS/build/install/bin/qgis)
==17204==  Address 0x2aec57b1 is 1 bytes inside a block of size 11 free'd
==17204==    at 0x4C287BE: free (vg_replace_malloc.c:446)
==17204==    by 0xBF5CC34: setlocale (setlocale.c:173)
==17204==    by 0x808B6A0: QgsCoordinateReferenceSystem::setProj4String(QString) (in /home/even/qgis-git/Quantum-GIS/build/install/lib/libqgis_core.so.1.9.0)
==17204==    by 0x808A401: QgsCoordinateReferenceSystem::createFromProj4(QString) (in /home/even/qgis-git/Quantum-GIS/build/install/lib/libqgis_core.so.1.9.0)
==17204==    by 0x7FC2F68: QgsDistanceArea::setEllipsoid(QString const&) (in /home/even/qgis-git/Quantum-GIS/build/install/lib/libqgis_core.so.1.9.0)
==17204==    by 0x6D23A3: QgsMeasureDialog::updateSettings() (in /home/even/qgis-git/Quantum-GIS/build/install/bin/qgis)
==17204==    by 0x6D200D: QgsMeasureDialog::QgsMeasureDialog(QgsMeasureTool*, QFlags<Qt::WindowType>) (in /home/even/qgis-git/Quantum-GIS/build/install/bin/qgis)
==17204==    by 0x6D5777: QgsMeasureTool::QgsMeasureTool(QgsMapCanvas*, bool) (in /home/even/qgis-git/Quantum-GIS/build/install/bin/qgis)
==17204==    by 0x553E4B: QgisApp::createCanvasTools() (in /home/even/qgis-git/Quantum-GIS/build/install/bin/qgis)
==17204==    by 0x544411: QgisApp::QgisApp(QSplashScreen*, bool, QWidget*, QFlags<Qt::WindowType>) (in /home/even/qgis-git/Quantum-GIS/build/install/bin/qgis)
==17204==    by 0x53DFF5: main (in /home/even/qgis-git/Quantum-GIS/build/install/bin/qgis)
==17204==
  • Loading branch information
rouault committed Sep 28, 2012
1 parent fa43064 commit 40b60bba7dedbf7f35ee2a6f1e15602928750d23
Showing with 5 additions and 1 deletion.
  1. +5 −1 src/core/qgscoordinatereferencesystem.cpp
@@ -900,7 +900,10 @@ void QgsCoordinateReferenceSystem::setDescription( QString theDescription )
}
void QgsCoordinateReferenceSystem::setProj4String( QString theProj4String )
{
const char *oldlocale = setlocale( LC_NUMERIC, NULL );
char *oldlocale = setlocale( LC_NUMERIC, NULL );
/* the next setlocale() invalides the return of previous setlocale() */
if (oldlocale != NULL)
oldlocale = strdup(oldlocale);

setlocale( LC_NUMERIC, "C" );
OSRDestroySpatialReference( mCRS );
@@ -916,6 +919,7 @@ void QgsCoordinateReferenceSystem::setProj4String( QString theProj4String )
#endif

setlocale( LC_NUMERIC, oldlocale );
free(oldlocale);
}
void QgsCoordinateReferenceSystem::setGeographicFlag( bool theGeoFlag )
{

0 comments on commit 40b60bb

Please sign in to comment.
You can’t perform that action at this time.