@@ -277,10 +277,12 @@ QgsGmlStreamingParser::QgsGmlStreamingParser( const QString& typeName,
277277 : mTypeName( typeName )
278278 , mTypeNameBA( mTypeName .toUtf8() )
279279 , mTypeNamePtr( mTypeNameBA .constData() )
280+ , mTypeNameUTF8Len( strlen( mTypeNamePtr ) )
280281 , mWkbType( QgsWkbTypes::Unknown )
281282 , mGeometryAttribute( geometryAttribute )
282283 , mGeometryAttributeBA( geometryAttribute.toUtf8() )
283284 , mGeometryAttributePtr( mGeometryAttributeBA .constData() )
285+ , mGeometryAttributeUTF8Len( strlen( mGeometryAttributePtr ) )
284286 , mFields( fields )
285287 , mIsException( false )
286288 , mTruncatedResponse( false )
@@ -315,6 +317,7 @@ QgsGmlStreamingParser::QgsGmlStreamingParser( const QString& typeName,
315317 mTypeName = mTypeName .mid ( index + 1 );
316318 mTypeNameBA = mTypeName .toUtf8 ();
317319 mTypeNamePtr = mTypeNameBA .constData ();
320+ mTypeNameUTF8Len = strlen ( mTypeNamePtr );
318321 }
319322
320323 mParser = XML_ParserCreateNS ( nullptr , NS_SEPARATOR );
@@ -340,8 +343,10 @@ QgsGmlStreamingParser::QgsGmlStreamingParser( const QList<LayerProperties>& laye
340343 bool invertAxisOrientation )
341344 : mLayerProperties( layerProperties )
342345 , mTypeNamePtr( nullptr )
346+ , mTypeNameUTF8Len( 0 )
343347 , mWkbType( QgsWkbTypes::Unknown )
344348 , mGeometryAttributePtr( nullptr )
349+ , mGeometryAttributeUTF8Len( 0 )
345350 , mFields( fields )
346351 , mIsException( false )
347352 , mTruncatedResponse( false )
@@ -397,13 +402,15 @@ QgsGmlStreamingParser::QgsGmlStreamingParser( const QList<LayerProperties>& laye
397402 mGeometryAttribute = mLayerProperties [0 ].mGeometryAttribute ;
398403 mGeometryAttributeBA = mGeometryAttribute .toUtf8 ();
399404 mGeometryAttributePtr = mGeometryAttributeBA .constData ();
405+ mGeometryAttributeUTF8Len = strlen ( mGeometryAttributePtr );
400406 int index = mTypeName .indexOf ( ' :' );
401407 if ( index != -1 && index < mTypeName .length () )
402408 {
403409 mTypeName = mTypeName .mid ( index + 1 );
404410 }
405411 mTypeNameBA = mTypeName .toUtf8 ();
406412 mTypeNamePtr = mTypeNameBA .constData ();
413+ mTypeNameUTF8Len = strlen ( mTypeNamePtr );
407414 }
408415
409416 mEndian = QgsApplication::endian ();
@@ -542,7 +549,7 @@ void QgsGmlStreamingParser::startElement( const XML_Char* el, const XML_Char** a
542549 }
543550 }
544551 }
545- else if ( localNameLen == mGeometryAttribute . size ( ) &&
552+ else if ( localNameLen == static_cast < int >( mGeometryAttributeUTF8Len ) &&
546553 memcmp ( pszLocalName, mGeometryAttributePtr , localNameLen ) == 0 )
547554 {
548555 mParseModeStack .push ( QgsGmlStreamingParser::Geometry );
@@ -606,6 +613,7 @@ void QgsGmlStreamingParser::startElement( const XML_Char* el, const XML_Char** a
606613 }
607614 mGeometryAttributeBA = mGeometryAttribute .toUtf8 ();
608615 mGeometryAttributePtr = mGeometryAttributeBA .constData ();
616+ mGeometryAttributeUTF8Len = strlen ( mGeometryAttributePtr );
609617 mParseModeStack .push ( QgsGmlStreamingParser::FeatureTuple );
610618 QString id;
611619 if ( mGMLNameSpaceURI .isEmpty () )
@@ -634,7 +642,8 @@ void QgsGmlStreamingParser::startElement( const XML_Char* el, const XML_Char** a
634642 }
635643 }
636644 else if ( theParseMode == None &&
637- localNameLen == mTypeName .size () && memcmp ( pszLocalName, mTypeNamePtr , mTypeName .size () ) == 0 )
645+ localNameLen == static_cast <int >( mTypeNameUTF8Len ) &&
646+ memcmp ( pszLocalName, mTypeNamePtr , mTypeNameUTF8Len ) == 0 )
638647 {
639648 Q_ASSERT ( !mCurrentFeature );
640649 mCurrentFeature = new QgsFeature ( mFeatureCount );
@@ -857,7 +866,8 @@ void QgsGmlStreamingParser::endElement( const XML_Char* el )
857866
858867 setAttribute ( mAttributeName , mStringCash );
859868 }
860- else if ( theParseMode == Geometry && localNameLen == mGeometryAttribute .size () &&
869+ else if ( theParseMode == Geometry &&
870+ localNameLen == static_cast <int >( mGeometryAttributeUTF8Len ) &&
861871 memcmp ( pszLocalName, mGeometryAttributePtr , localNameLen ) == 0 )
862872 {
863873 mParseModeStack .pop ();
@@ -935,8 +945,9 @@ void QgsGmlStreamingParser::endElement( const XML_Char* el )
935945 }
936946 else if (( theParseMode == Tuple && !mTypeNamePtr &&
937947 LOCALNAME_EQUALS ( " Tuple" ) ) ||
938- ( theParseMode == Feature && localNameLen == mTypeName .size () &&
939- memcmp ( pszLocalName, mTypeNamePtr , mTypeName .size () ) == 0 ) )
948+ ( theParseMode == Feature &&
949+ localNameLen == static_cast <int >( mTypeNameUTF8Len ) &&
950+ memcmp ( pszLocalName, mTypeNamePtr , mTypeNameUTF8Len ) == 0 ) )
940951 {
941952 Q_ASSERT ( mCurrentFeature );
942953 if ( !mCurrentFeature ->hasGeometry () )
0 commit comments