Oops. There's another occurrence of the same thing a few dozen lines later. This new patch fixes both of them (in the same grotty manner :) Firefox now seems crash-free as far as unaligned word accesses are concerned.
M
--- xulrunner-1.9~rc1.orig/toolkit/components/url-classifier/src/nsUrlClassifierDBService.cpp 2008-05-07 21:33:45.000000000 +0100 +++ xulrunner-1.9~rc1/toolkit/components/url-classifier/src/nsUrlClassifierDBService.cpp 2008-06-02 10:09:06.000000000 +0100 @@ -2020,8 +2020,20 @@ return NS_ERROR_FAILURE; } const nsCSubstring& str = Substring(chunk, start, 4); +#if 0 + // You can't just cast a char* to an int* and access through it const PRUint32 *p = reinterpret_cast<const PRUint32*>(str.BeginReading()); entry->mAddChunkId = PR_ntohl(*p); +#else + // the old-school way... + union { + PRUint32 i; + char c[4]; + } u; + + memcpy(u.c, reinterpret_cast<const char *>(str.BeginReading()), 4); + entry->mAddChunkId = PR_ntohl(u.i); +#endif if (entry->mAddChunkId == 0) { NS_WARNING("Received invalid chunk number."); return NS_ERROR_FAILURE; @@ -2049,8 +2061,20 @@ if (chunkType == CHUNK_SUB) { const nsCSubstring& str = Substring(chunk, start, 4); +#if 0 + // You can't just cast a char* to an int* and access through it const PRUint32 *p = reinterpret_cast<const PRUint32*>(str.BeginReading()); entry->mAddChunkId = PR_ntohl(*p); +#else + // the old-school way... + union { + PRUint32 i; + char c[4]; + } u; + + memcpy(u.c, reinterpret_cast<const char *>(str.BeginReading()), 4); + entry->mAddChunkId = PR_ntohl(u.i); +#endif if (entry->mAddChunkId == 0) { NS_WARNING("Received invalid chunk number."); return NS_ERROR_FAILURE;