Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Fix leak when a transform error occurs while transforming linestrings
- Loading branch information
Showing
with
11 additions
and
12 deletions.
-
+11
−12
src/core/geometry/qgslinestring.cpp
|
@@ -786,24 +786,23 @@ int QgsLineString::dimension() const |
|
|
|
|
|
void QgsLineString::transform( const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection d, bool transformZ ) |
|
|
{ |
|
|
double *zArray = mZ.data(); |
|
|
|
|
|
double *zArray = nullptr; |
|
|
bool hasZ = is3D(); |
|
|
int nPoints = numPoints(); |
|
|
bool useDummyZ = !hasZ || !transformZ; |
|
|
if ( useDummyZ ) |
|
|
|
|
|
// it's possible that transformCoords will throw an exception - so we need to use |
|
|
// a smart pointer for the dummy z values in order to ensure that they always get cleaned up |
|
|
std::unique_ptr< double[] > dummyZ; |
|
|
if ( !hasZ || !transformZ ) |
|
|
{ |
|
|
zArray = new double[nPoints]; |
|
|
for ( int i = 0; i < nPoints; ++i ) |
|
|
{ |
|
|
zArray[i] = 0; |
|
|
} |
|
|
dummyZ.reset( new double[nPoints]() ); |
|
|
zArray = dummyZ.get(); |
|
|
} |
|
|
ct.transformCoords( nPoints, mX.data(), mY.data(), zArray, d ); |
|
|
if ( useDummyZ ) |
|
|
else |
|
|
{ |
|
|
delete[] zArray; |
|
|
zArray = mZ.data(); |
|
|
} |
|
|
ct.transformCoords( nPoints, mX.data(), mY.data(), zArray, d ); |
|
|
clearCache(); |
|
|
} |
|
|
|
|
|