Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Store result of OGR_FD_GetGeomType into a QGis::WkbType, not in an in…
…t, which causes an integer overflow
  • Loading branch information
manisandro committed Dec 2, 2014
1 parent d034a66 commit 81895f9
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
14 changes: 7 additions & 7 deletions src/core/qgsvectorlayer.cpp
Expand Up @@ -650,7 +650,7 @@ bool QgsVectorLayer::hasGeometryType() const

QGis::WkbType QgsVectorLayer::wkbType() const
{
return ( QGis::WkbType )( mWkbType );
return mWkbType;
}

QgsRectangle QgsVectorLayer::boundingBoxOfSelected()
Expand Down Expand Up @@ -2143,7 +2143,7 @@ bool QgsVectorLayer::deleteAttributes( QList<int> attrs )

qSort( attrs.begin(), attrs.end(), qGreater<int>() );

Q_FOREACH ( int attr, attrs )
Q_FOREACH( int attr, attrs )
{
if ( deleteAttribute( attr ) )
{
Expand Down Expand Up @@ -2839,7 +2839,7 @@ void QgsVectorLayer::uniqueValues( int index, QList<QVariant> &uniqueValues, int
if ( mEditBuffer )
{
QSet<QString> vals;
Q_FOREACH ( const QVariant& v, uniqueValues )
Q_FOREACH( const QVariant& v, uniqueValues )
{
vals << v.toString();
}
Expand Down Expand Up @@ -3565,13 +3565,13 @@ void QgsVectorLayer::invalidateSymbolCountedFlag()

void QgsVectorLayer::onRelationsLoaded()
{
Q_FOREACH ( QgsAttributeEditorElement* elem, mAttributeEditorElements )
Q_FOREACH( QgsAttributeEditorElement* elem, mAttributeEditorElements )
{
if ( elem->type() == QgsAttributeEditorElement::AeTypeContainer )
{
QgsAttributeEditorContainer* cont = dynamic_cast< QgsAttributeEditorContainer* >( elem );
QList<QgsAttributeEditorElement*> relations = cont->findElements( QgsAttributeEditorElement::AeTypeRelation );
Q_FOREACH ( QgsAttributeEditorElement* relElem, relations )
Q_FOREACH( QgsAttributeEditorElement* relElem, relations )
{
QgsAttributeEditorRelation* rel = dynamic_cast< QgsAttributeEditorRelation* >( relElem );
rel->init( QgsProject::instance()->relationManager() );
Expand Down Expand Up @@ -3627,7 +3627,7 @@ QDomElement QgsAttributeEditorContainer::toDomElement( QDomDocument& doc ) const
QDomElement elem = doc.createElement( "attributeEditorContainer" );
elem.setAttribute( "name", mName );

Q_FOREACH ( QgsAttributeEditorElement* child, mChildren )
Q_FOREACH( QgsAttributeEditorElement* child, mChildren )
{
elem.appendChild( child->toDomElement( doc ) );
}
Expand All @@ -3643,7 +3643,7 @@ QList<QgsAttributeEditorElement*> QgsAttributeEditorContainer::findElements( Qgs
{
QList<QgsAttributeEditorElement*> results;

Q_FOREACH ( QgsAttributeEditorElement* elem, mChildren )
Q_FOREACH( QgsAttributeEditorElement* elem, mChildren )
{
if ( elem->type() == type )
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectorlayer.h
Expand Up @@ -1735,7 +1735,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
QList< TabData > mTabs;

/** Geometry type as defined in enum WkbType (qgis.h) */
int mWkbType;
QGis::WkbType mWkbType;

/** Renderer object which holds the information about how to display the features */
QgsFeatureRendererV2 *mRendererV2;
Expand Down
2 changes: 1 addition & 1 deletion src/providers/ogr/qgsogrdataitems.cpp
Expand Up @@ -140,7 +140,7 @@ static QgsOgrLayerItem* dataItemForLayer( QgsDataItem* parentItem, QString name,
OGRFeatureDefnH hDef = OGR_L_GetLayerDefn( hLayer );

QgsLayerItem::LayerType layerType = QgsLayerItem::Vector;
int ogrType = QgsOgrProvider::getOgrGeomType( hLayer );
OGRwkbGeometryType ogrType = QgsOgrProvider::getOgrGeomType( hLayer );
switch ( ogrType )
{
case wkbUnknown:
Expand Down
6 changes: 3 additions & 3 deletions src/providers/ogr/qgsogrprovider.cpp
Expand Up @@ -695,10 +695,10 @@ void QgsOgrProvider::setEncoding( const QString& e )
}

// This is reused by dataItem
int QgsOgrProvider::getOgrGeomType( OGRLayerH ogrLayer )
OGRwkbGeometryType QgsOgrProvider::getOgrGeomType( OGRLayerH ogrLayer )
{
OGRFeatureDefnH fdef = OGR_L_GetLayerDefn( ogrLayer );
int geomType = wkbUnknown;
OGRwkbGeometryType geomType = wkbUnknown;
if ( fdef )
{
geomType = OGR_FD_GetGeomType( fdef );
Expand Down Expand Up @@ -935,7 +935,7 @@ size_t QgsOgrProvider::layerCount() const
*/
QGis::WkbType QgsOgrProvider::geometryType() const
{
return ( QGis::WkbType ) geomType;
return static_cast<QGis::WkbType>( geomType );
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/providers/ogr/qgsogrprovider.h
Expand Up @@ -248,7 +248,7 @@ class QgsOgrProvider : public QgsVectorDataProvider
virtual bool doesStrictFeatureTypeCheck() const { return false;}

/** return OGR geometry type */
static int getOgrGeomType( OGRLayerH ogrLayer );
static OGRwkbGeometryType getOgrGeomType( OGRLayerH ogrLayer );

/** Get single flatten geometry type */
static OGRwkbGeometryType ogrWkbSingleFlatten( OGRwkbGeometryType type );
Expand Down Expand Up @@ -325,7 +325,7 @@ class QgsOgrProvider : public QgsVectorDataProvider
bool valid;
//! Flag to indicate that spatial intersect should be used in selecting features
bool mUseIntersect;
int geomType;
OGRwkbGeometryType geomType;
long featuresCounted;

//! Data has been modified - REPACK before creating a spatialindex
Expand Down

0 comments on commit 81895f9

Please sign in to comment.