[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/KDE/4.2/kdelibs/kdeui/util
From: Michael Pyne <mpyne () purinchu ! net>
Date: 2009-05-29 14:09:26
Message-ID: 1243606166.437031.1510.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 974498 by mpyne:
Backport invalid aliasing crash for for KPixmapCache to 4.2 branch.
This may possibly make it to 4.2.4 but that's up to release team as it's
past tagging date.
BUG:182026
M +13 -13 kpixmapcache.cpp
--- branches/KDE/4.2/kdelibs/kdeui/util/kpixmapcache.cpp #974497:974498
@@ -289,15 +289,11 @@
// Holds info about mmapped file
struct MmapInfo
{
- MmapInfo() { file = 0; memory = 0; }
+ MmapInfo() { file = 0; indexHeader = 0; }
QFile* file; // If this is not null, then the file is mmapped
- // Convenience aliases. This probably breaks some C++ aliasing rule or something. :-/
- union {
- char* memory;
- KPixmapCacheIndexHeader *indexHeader;
- KPixmapCacheDataHeader *dataHeader;
- };
+ // This points to the mmap'ed file area.
+ KPixmapCacheIndexHeader *indexHeader;
quint32 size; // Number of currently used bytes
quint32 available; // Number of available bytes (including those reserved for mmap)
@@ -474,9 +470,9 @@
info->file = 0;
return false;
}
- info->memory = reinterpret_cast<char*>(indexMem);
+ info->indexHeader = reinterpret_cast<KPixmapCacheIndexHeader *>(indexMem);
#ifdef HAVE_MADVISE
- madvise(info->memory, info->size, MADV_WILLNEED);
+ madvise(indexMem, info->size, MADV_WILLNEED);
#endif
info->file->close();
@@ -496,8 +492,8 @@
void KPixmapCache::Private::unmmapFile(MmapInfo* info)
{
if (info->file) {
- info->file->unmap(reinterpret_cast<uchar*>(info->memory));
- info->memory = 0;
+ info->file->unmap(reinterpret_cast<uchar*>(info->indexHeader));
+ info->indexHeader = 0;
info->available = 0;
info->size = 0;
@@ -523,7 +519,9 @@
fi.refresh();
if(fi.exists() && fi.size() == mIndexMmapInfo.available) {
// Create the device
- device = new KPCMemoryDevice(mIndexMmapInfo.memory, &mIndexMmapInfo.size, mIndexMmapInfo.available);
+ device = new KPCMemoryDevice(
+ reinterpret_cast<char*>(mIndexMmapInfo.indexHeader),
+ &mIndexMmapInfo.size, mIndexMmapInfo.available);
}
// Is it possible to have a valid cache with no file? If not it would be easier
@@ -592,7 +590,9 @@
fi.refresh();
if (fi.exists() && fi.size() == mDataMmapInfo.available) {
// Create the device
- return new KPCMemoryDevice(mDataMmapInfo.memory, &mDataMmapInfo.size, mDataMmapInfo.available);
+ return new KPCMemoryDevice(
+ reinterpret_cast<char*>(mDataMmapInfo.indexHeader),
+ &mDataMmapInfo.size, mDataMmapInfo.available);
}
else
return 0;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic