Skip to content
Permalink
Browse files
Avoid a segfault when NULL layer is passed to vector writer
  • Loading branch information
wonder-sk committed Aug 4, 2011
1 parent aa121bf commit 2d35b16aaeb0cfb0154078371188fe67db3c8ff9
Showing with 12 additions and 1 deletion.
  1. +6 −1 python/core/qgsvectorfilewriter.sip
  2. +5 −0 src/core/qgsvectorfilewriter.cpp
  3. +1 −0 src/core/qgsvectorfilewriter.h
@@ -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
@@ -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
@@ -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

0 comments on commit 2d35b16

Please sign in to comment.