Skip to content

Commit

Permalink
catch QgsWkbException in QgsGeometryFactory (passes test from PR#2751)
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Feb 9, 2016
1 parent 89b49a1 commit 731a3fe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
14 changes: 13 additions & 1 deletion src/core/geometry/qgsgeometryfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "qgsmultipolygonv2.h"
#include "qgsmultisurfacev2.h"
#include "qgswkbtypes.h"
#include "qgslogger.h"

QgsAbstractGeometryV2* QgsGeometryFactory::geomFromWkb( QgsConstWkbPtr wkbPtr )
{
Expand All @@ -43,7 +44,18 @@ QgsAbstractGeometryV2* QgsGeometryFactory::geomFromWkb( QgsConstWkbPtr wkbPtr )
geom = geomFromWkbType( type );

if ( geom )
geom->fromWkb( wkbPtr );
{
try
{
geom->fromWkb( wkbPtr );
}
catch ( const QgsWkbException &e )
{
QgsDebugMsg( "WKB exception: " + e.what() );
delete geom;
geom = nullptr;
}
}

return geom;
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/geometry/qgswkbptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class CORE_EXPORT QgsWkbPtr
unsigned char *mStart;
unsigned char *mEnd;

void verify( int size ) const { Q_ASSERT( mP && mP + size <= mEnd ); if ( !mP || mP + size > mEnd ) throw QgsWkbException( "wkb access out of bounds" ); }
void verify( int size ) const { if ( !mP || mP + size > mEnd ) throw QgsWkbException( "wkb access out of bounds" ); }

template<typename T> void read( T& v ) const
{
Expand Down Expand Up @@ -93,7 +93,7 @@ class CORE_EXPORT QgsConstWkbPtr
unsigned char *mEnd;
mutable bool mEndianSwap;

void verify( int size ) const { Q_ASSERT( mP && mP + size <= mEnd ); if ( !mP || mP + size > mEnd ) throw QgsWkbException( "wkb access out of bounds" ); }
void verify( int size ) const { if ( !mP || mP + size > mEnd ) throw QgsWkbException( "wkb access out of bounds" ); }

template<typename T> void read( T& v ) const
{
Expand Down

0 comments on commit 731a3fe

Please sign in to comment.