Skip to content

Commit bb31a2d

Browse files
committed
fix crash adding features without geometry to a geometry layer
1 parent faf46b6 commit bb31a2d

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

src/providers/postgres/qgspostgresprovider.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2368,6 +2368,12 @@ bool QgsPostgresProvider::changeAttributeValues( const QgsChangedAttributesMap &
23682368

23692369
void QgsPostgresProvider::appendGeomParam( QgsGeometry *geom, QStringList &params ) const
23702370
{
2371+
if ( !geom )
2372+
{
2373+
params << QString::null;
2374+
return;
2375+
}
2376+
23712377
QString param;
23722378
unsigned char *buf = geom->asWkb();
23732379
for ( uint i = 0; i < geom->wkbSize(); ++i )

src/providers/spatialite/qgsspatialiteprovider.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3674,15 +3674,22 @@ bool QgsSpatiaLiteProvider::addFeatures( QgsFeatureList & flist )
36743674
if ( !mGeometryColumn.isNull() )
36753675
{
36763676
// binding GEOMETRY to Prepared Statement
3677-
unsigned char *wkb = NULL;
3678-
size_t wkb_size;
3679-
convertFromGeosWKB( features->geometry()->asWkb(),
3680-
features->geometry()->wkbSize(),
3681-
&wkb, &wkb_size, nDims );
3682-
if ( !wkb )
3677+
if ( !features->geometry() )
3678+
{
36833679
sqlite3_bind_null( stmt, ++ia );
3680+
}
36843681
else
3685-
sqlite3_bind_blob( stmt, ++ia, wkb, wkb_size, free );
3682+
{
3683+
unsigned char *wkb = NULL;
3684+
size_t wkb_size;
3685+
convertFromGeosWKB( features->geometry()->asWkb(),
3686+
features->geometry()->wkbSize(),
3687+
&wkb, &wkb_size, nDims );
3688+
if ( !wkb )
3689+
sqlite3_bind_null( stmt, ++ia );
3690+
else
3691+
sqlite3_bind_blob( stmt, ++ia, wkb, wkb_size, free );
3692+
}
36863693
}
36873694

36883695
for ( QgsAttributeMap::const_iterator it = attributevec.begin(); it != attributevec.end(); it++ )

0 commit comments

Comments
 (0)