diff options
author | Jason Barron <jason.barron@nokia.com> | 2010-08-24 15:00:59 (GMT) |
---|---|---|
committer | Jason Barron <jason.barron@nokia.com> | 2010-09-10 14:42:39 (GMT) |
commit | 771cfe6f172820a1a370255cb74e066913408a6f (patch) | |
tree | 2c8fb29f55c98e37efafd8dde7824aa8fe866daa /src/openvg | |
parent | 8b1c78c80181e6125d39b64f7ffa698f50ed8042 (diff) | |
download | Qt-771cfe6f172820a1a370255cb74e066913408a6f.zip Qt-771cfe6f172820a1a370255cb74e066913408a6f.tar.gz Qt-771cfe6f172820a1a370255cb74e066913408a6f.tar.bz2 |
Fix crash in OpenVG when failing to allocate large VGImages.
The reclaimSpace() function of the VG image pool was crashing when
attempting to free up space for a large image. It was calling
moveToHeadOfLRU() which adds the image to the pool. If the pixmap is
large enough so that it pushes all the others out, then it will be the
only pixmap left in the pool when this function returns. This is
problematic because this pixmap is not permanent so it could be
deleted. If that happens, then subsequent calls to this function will
crash because the LRU pixmap has been deleted.
The fix is to check if the pixmap was in the pool to begin with and
if not, then be sure to remove it before returning from this function.
Task-number: QT-3652
Reviewed-by: Jani Hautakangas
Diffstat (limited to 'src/openvg')
-rw-r--r-- | src/openvg/qvgimagepool.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/openvg/qvgimagepool.cpp b/src/openvg/qvgimagepool.cpp index 78277aa..0c236ea 100644 --- a/src/openvg/qvgimagepool.cpp +++ b/src/openvg/qvgimagepool.cpp @@ -154,16 +154,23 @@ bool QVGImagePool::reclaimSpace(VGImageFormat format, Q_UNUSED(width); Q_UNUSED(height); - if (data) + bool succeeded = false; + bool wasInLRU = false; + if (data) { + wasInLRU = data->inLRU; moveToHeadOfLRU(data); + } QVGPixmapData *lrudata = pixmapLRU(); if (lrudata && lrudata != data) { lrudata->reclaimImages(); - return true; + succeeded = true; } - return false; + if (data && !wasInLRU) + removeFromLRU(data); + + return succeeded; } void QVGImagePool::hibernate() |