diff --git a/src/core/qgsogrutils.cpp b/src/core/qgsogrutils.cpp index f2c911ce5ee..addcc7ee8fc 100644 --- a/src/core/qgsogrutils.cpp +++ b/src/core/qgsogrutils.cpp @@ -226,8 +226,12 @@ QVariant QgsOgrUtils::getOgrFeatureAttribute( OGRFeatureH ogrFet, const QgsField { int size = 0; const GByte *b = OGR_F_GetFieldAsBinary( ogrFet, attIndex, &size ); + + // QByteArray::fromRawData is funny. It doesn't take ownership of the data, so we have to explicitly call + // detach on it to force a copy which owns the data QByteArray ba = QByteArray::fromRawData( reinterpret_cast( b ), size ); ba.detach(); + value = ba; break; }