Skip to content

Commit d2679d6

Browse files
committed
another fix for gml wkb assembly (fixes #14315)
1 parent 1ffccf0 commit d2679d6

File tree

3 files changed

+15
-19
lines changed

3 files changed

+15
-19
lines changed

src/core/geometry/qgsgeometry.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,6 @@ QgsGeometry* QgsGeometry::fromRect( const QgsRectangle& rect )
235235

236236
void QgsGeometry::fromWkb( unsigned char *wkb, int length )
237237
{
238-
Q_UNUSED( length );
239-
240238
detach( false );
241239

242240
if ( d->geometry )

src/core/qgsgml.cpp

+14-14
Original file line numberDiff line numberDiff line change
@@ -377,10 +377,10 @@ void QgsGml::endElement( const XML_Char* el )
377377
else if ( theParseMode == feature && localName == mTypeName )
378378
{
379379
Q_ASSERT( mCurrentFeature );
380-
if ( mCurrentWKBSize > 0 )
380+
if ( mCurrentWKB.size() > 0 )
381381
{
382382
QgsGeometry *g = new QgsGeometry();
383-
g->fromWkb( mCurrentWKB, mCurrentWKBSize );
383+
g->fromWkb( mCurrentWKB, mCurrentWKB.size() );
384384
mCurrentFeature->setGeometry( g );
385385
mCurrentWKB = QgsWkbPtr( nullptr, 0 );
386386
}
@@ -767,10 +767,10 @@ int QgsGml::getRingWKB( QgsWkbPtr &wkbPtr, const QList<QgsPoint>& ringCoordinate
767767

768768
int QgsGml::createMultiLineFromFragments()
769769
{
770-
mCurrentWKBSize = 1 + 2 * sizeof( int ) + totalWKBFragmentSize();
771-
mCurrentWKB = QgsWkbPtr( new unsigned char[mCurrentWKBSize], mCurrentWKBSize );
770+
int size = 1 + 2 * sizeof( int ) + totalWKBFragmentSize();
771+
mCurrentWKB = QgsWkbPtr( new unsigned char[size], size );
772772

773-
QgsWkbPtr wkbPtr( mCurrentWKB, mCurrentWKBSize );
773+
QgsWkbPtr wkbPtr( mCurrentWKB );
774774

775775
wkbPtr << mEndian << QGis::WKBMultiLineString << mCurrentWKBFragments.constBegin()->size();
776776

@@ -790,8 +790,8 @@ int QgsGml::createMultiLineFromFragments()
790790

791791
int QgsGml::createMultiPointFromFragments()
792792
{
793-
mCurrentWKBSize = 1 + 2 * sizeof( int ) + totalWKBFragmentSize();
794-
mCurrentWKB = QgsWkbPtr( new unsigned char[mCurrentWKBSize], mCurrentWKBSize );
793+
int size = 1 + 2 * sizeof( int ) + totalWKBFragmentSize();
794+
mCurrentWKB = QgsWkbPtr( new unsigned char[size], size );
795795

796796
QgsWkbPtr wkbPtr( mCurrentWKB );
797797
wkbPtr << mEndian << QGis::WKBMultiPoint << mCurrentWKBFragments.constBegin()->size();
@@ -812,8 +812,8 @@ int QgsGml::createMultiPointFromFragments()
812812

813813
int QgsGml::createPolygonFromFragments()
814814
{
815-
mCurrentWKBSize = 1 + 2 * sizeof( int ) + totalWKBFragmentSize();
816-
mCurrentWKB = QgsWkbPtr( new unsigned char[mCurrentWKBSize], mCurrentWKBSize );
815+
int size = 1 + 2 * sizeof( int ) + totalWKBFragmentSize();
816+
mCurrentWKB = QgsWkbPtr( new unsigned char[size], size );
817817

818818
QgsWkbPtr wkbPtr( mCurrentWKB );
819819
wkbPtr << mEndian << QGis::WKBPolygon << mCurrentWKBFragments.constBegin()->size();
@@ -833,12 +833,12 @@ int QgsGml::createPolygonFromFragments()
833833

834834
int QgsGml::createMultiPolygonFromFragments()
835835
{
836-
mCurrentWKBSize = 0;
837-
mCurrentWKBSize += 1 + 2 * sizeof( int );
838-
mCurrentWKBSize += totalWKBFragmentSize();
839-
mCurrentWKBSize += mCurrentWKBFragments.size() * ( 1 + 2 * sizeof( int ) ); //fragments are just the rings
836+
int size = 0;
837+
size += 1 + 2 * sizeof( int );
838+
size += totalWKBFragmentSize();
839+
size += mCurrentWKBFragments.size() * ( 1 + 2 * sizeof( int ) ); //fragments are just the rings
840840

841-
mCurrentWKB = QgsWkbPtr( new unsigned char[mCurrentWKBSize], mCurrentWKBSize );
841+
mCurrentWKB = QgsWkbPtr( new unsigned char[size], size );
842842

843843
QgsWkbPtr wkbPtr( mCurrentWKB );
844844
wkbPtr << ( char ) mEndian << QGis::WKBMultiPolygon << mCurrentWKBFragments.size();

src/core/qgsgml.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ class CORE_EXPORT QgsGml : public QObject
170170
int getRingWKB( QgsWkbPtr &wkbPtr, const QList<QgsPoint>& ringCoordinates ) const;
171171
/** Creates a multiline from the information in mCurrentWKBFragments and
172172
* mCurrentWKBFragmentSizes. Assign the result. The multiline is in
173-
* mCurrentWKB and mCurrentWKBSize. The function deletes the memory in
173+
* mCurrentWKB. The function deletes the memory in
174174
* mCurrentWKBFragments. Returns 0 in case of success.
175175
*/
176176
int createMultiLineFromFragments();
@@ -226,8 +226,6 @@ class CORE_EXPORT QgsGml : public QObject
226226
int mFeatureCount;
227227
/** The total WKB for a feature*/
228228
QgsWkbPtr mCurrentWKB;
229-
/** The total WKB size for a feature*/
230-
int mCurrentWKBSize;
231229
QgsRectangle mCurrentExtent;
232230
/** WKB intermediate storage during parsing. For points and lines, no
233231
* intermediate WKB is stored at all. For multipoints and multilines and

0 commit comments

Comments
 (0)