Skip to content

Commit

Permalink
Avoid a segfault when NULL layer is passed to vector writer
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Aug 4, 2011
1 parent aa121bf commit 2d35b16
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion python/core/qgsvectorfilewriter.sip
Expand Up @@ -21,7 +21,12 @@ public:
NoError = 0,
ErrDriverNotFound,
ErrCreateDataSource,
ErrCreateLayer
ErrCreateLayer,
ErrAttributeTypeUnsupported,
ErrAttributeCreationFailed,
ErrProjection, // added in 1.5
ErrFeatureWriteFailed, // added in 1.6
ErrInvalidLayer, // added in 2.0
};

/** Write contents of vector layer to a shapefile
Expand Down
5 changes: 5 additions & 0 deletions src/core/qgsvectorfilewriter.cpp
Expand Up @@ -588,6 +588,11 @@ QgsVectorFileWriter::writeAsVectorFormat( QgsVectorLayer* layer,
QgsCoordinateTransform* ct = 0;
int shallTransform = false;

if ( layer == NULL )
{
return ErrInvalidLayer;
}

if ( destCRS && destCRS->isValid() )
{
// This means we should transform
Expand Down
1 change: 1 addition & 0 deletions src/core/qgsvectorfilewriter.h
Expand Up @@ -53,6 +53,7 @@ class CORE_EXPORT QgsVectorFileWriter
ErrAttributeCreationFailed,
ErrProjection, // added in 1.5
ErrFeatureWriteFailed, // added in 1.6
ErrInvalidLayer, // added in 2.0
};

/** Write contents of vector layer to a shapefile
Expand Down

0 comments on commit 2d35b16

Please sign in to comment.