QPicture: check that pictureFormat doesn't return dangling pointers
The function returns a const char * out of a QByteArray. We must be sure that the QByteArray outlives the function, otherwise the pointer returned would be dangling. Add an assertion for that. Found by clazy. Change-Id: I3416af4eb5ec79ddb3e4baf3bdcfe046b44d4225 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
This commit is contained in:
parent
cdc79f5ebc
commit
d7db2b4359
@ -1206,7 +1206,12 @@ QT_END_INCLUDE_NAMESPACE
|
|||||||
|
|
||||||
const char* QPicture::pictureFormat(const QString &fileName)
|
const char* QPicture::pictureFormat(const QString &fileName)
|
||||||
{
|
{
|
||||||
return QPictureIO::pictureFormat(fileName);
|
const QByteArray format = QPictureIO::pictureFormat(fileName);
|
||||||
|
// This function returns a const char * from a QByteArray.
|
||||||
|
// Double check that the QByteArray is not detached, otherwise
|
||||||
|
// we would return a dangling pointer.
|
||||||
|
Q_ASSERT(!format.isDetached());
|
||||||
|
return format;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
Loading…
x
Reference in New Issue
Block a user