Index: kiconcache.cpp
===================================================================
--- kiconcache.cpp	(revision 812533)
+++ kiconcache.cpp	(working copy)
@@ -128,7 +128,7 @@
     quint32 version;
     stream >> version;
     if (version != KDE_ICONCACHE_VERSION) {
-        kDebug(264) << "Obsolete iconcache version, will recreate";
+        kDebug(264) << "Obsolete iconcache version" << version << "will recreate";
         return false;
     }
 
Index: kpixmapcache.cpp
===================================================================
--- kpixmapcache.cpp	(revision 812533)
+++ kpixmapcache.cpp	(working copy)
@@ -56,7 +56,7 @@
 #define USE_MMAP
 #endif
 
-#define KPIXMAPCACHE_VERSION 0x000206
+#define KPIXMAPCACHE_VERSION 0x000207
 
 namespace {
 
@@ -208,7 +208,6 @@
 
 } // namespace
 
-
 class KPixmapCache::Private
 {
 public:
@@ -251,9 +250,10 @@
 
     KPixmapCache* q;
 
-    static const char* kpc_magic;
+    static const char *const kpc_magic;
     static const int kpc_magic_len;
     static const int kpc_header_len;
+
     quint32 mHeaderSize;  // full size of the index header, including custom (subclass') header data
     quint32 mIndexRootOffset;  // offset of the first entry in index file
 
@@ -368,17 +368,30 @@
 };
 
 // Magic in the cache files
-const char* KPixmapCache::Private::kpc_magic = "KDE PIXMAP CACHE ";
+
+const char *const KPixmapCache::Private::kpc_magic = "KDE PIXMAP CACHE ";
 const int KPixmapCache::Private::kpc_magic_len = qstrlen(KPixmapCache::Private::kpc_magic);
-// Whole header is magic + version (4 bytes)
-const int KPixmapCache::Private::kpc_header_len = KPixmapCache::Private::kpc_magic_len + 4;
 
+// Add in padding such that the next byte after the header is already pointer
+// aligned.  i.e. if this architecture requires 4 byte alignment for pointers
+// and kpc_magic is 22 bytes, make the header 24 bytes long.
+// The header itself is the magic plus the 4 bytes for the version ID.
+const int KPixmapCache::Private::kpc_header_len =
+    KPixmapCache::Private::kpc_magic_len + 4
 
+    // This is the amount of padding required:
+    + ( // Wow, this looks like LISP...
+        (sizeof(void*) - ((KPixmapCache::Private::kpc_magic_len + 4) % sizeof(void*)))
+    ) % sizeof(void*);
+
+
 KPixmapCache::Private::Private(KPixmapCache* _q)
 {
     q = _q;
     mRemovalThread = 0;
 
+    // the size offset must be to a properly aligned memory address, see above
+    // for how we get kpc_header_len to do that.
     KPCMemoryDevice::setSizeEntryOffset(kpc_header_len);  // ugly
 }
 
@@ -457,7 +470,7 @@
         info->file = 0;
         return false;
     }
-    info->memory = reinterpret_cast<char*>(indexMem);
+    info->memory = static_cast<char*>(indexMem);
 #ifdef HAVE_MADVISE
     madvise(info->memory, info->size, MADV_WILLNEED);
 #endif
@@ -659,11 +672,11 @@
         QDataStream stream(&f);
 
         // Check header and version
-        char buf[100];
+        QByteArray buf(kpc_magic_len + 1, '\0');
         quint32 version;
-        stream.readRawData(buf, kpc_magic_len);
+        stream.readRawData(buf.data(), kpc_magic_len);
         stream >> version;
-        if (qstrncmp(buf, kpc_magic, kpc_magic_len) == 0) {
+        if (qstrncmp(buf.constData(), kpc_magic, kpc_magic_len) == 0) {
             if (version == KPIXMAPCACHE_VERSION) {
                 return true;
             } else if (version < KPIXMAPCACHE_VERSION) {
@@ -1123,6 +1136,8 @@
     QDataStream istream(&indexfile);
     istream.writeRawData(d->kpc_magic, d->kpc_magic_len);
     istream << (quint32)KPIXMAPCACHE_VERSION;
+    for(int i = d->kpc_magic_len + sizeof(quint32); i < d->kpc_header_len; ++i)
+        istream << quint8(0); // Add padding
     // Write invalid file size, valid one will be written later by mmap code
     d->mIndexMmapInfo.size = 0;
     istream << d->mIndexMmapInfo.size;
@@ -1140,8 +1155,12 @@
         return false;
     }
     QDataStream dstream(&datafile);
+    kDebug(264) << "Magic len:" << d->kpc_magic_len;
+    kDebug(264) << "Header len:" << d->kpc_header_len;
     dstream.writeRawData(d->kpc_magic, d->kpc_magic_len);
     dstream << (quint32)KPIXMAPCACHE_VERSION;
+    for(int i = d->kpc_magic_len + sizeof(quint32); i < d->kpc_header_len; ++i)
+        dstream << quint8(0); // Add padding
     d->mDataMmapInfo.size = 0;
     dstream << d->mDataMmapInfo.size;
 
