Skip to content
Permalink
Browse files

catch QgsWkbException in QgsGeometryFactory (passes test from PR#2751)

  • Loading branch information
jef-n committed Feb 1, 2016
1 parent 89b49a1 commit 731a3fe1cce0e0085a8a806793b9ad2540ed14cc
Showing with 15 additions and 3 deletions.
  1. +13 −1 src/core/geometry/qgsgeometryfactory.cpp
  2. +2 −2 src/core/geometry/qgswkbptr.h
@@ -28,6 +28,7 @@
#include "qgsmultipolygonv2.h"
#include "qgsmultisurfacev2.h"
#include "qgswkbtypes.h"
#include "qgslogger.h"

QgsAbstractGeometryV2* QgsGeometryFactory::geomFromWkb( QgsConstWkbPtr wkbPtr )
{
@@ -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;
}
@@ -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
{
@@ -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
{

0 comments on commit 731a3fe

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