Bug 1363882 - Remove casting address of inactive member union result.hash
MozReview-Commit-ID: 3pVaVJ1EJZu
--- a/toolkit/components/url-classifier/LookupCache.h
+++ b/toolkit/components/url-classifier/LookupCache.h
@@ -39,17 +39,23 @@ public:
const Completion &CompleteHash() {
MOZ_ASSERT(!mNoise);
return hash.complete;
}
nsCString PartialHash() {
MOZ_ASSERT(mPartialHashLength <= COMPLETE_SIZE);
- return nsCString(reinterpret_cast<char*>(hash.complete.buf), mPartialHashLength);
+ if (mNoise) {
+ return nsCString(reinterpret_cast<char*>(hash.fixedLengthPrefix.buf),
+ PREFIX_SIZE);
+ } else {
+ return nsCString(reinterpret_cast<char*>(hash.complete.buf),
+ mPartialHashLength);
+ }
}
nsCString PartialHashHex() {
nsAutoCString hex;
for (size_t i = 0; i < mPartialHashLength; i++) {
hex.AppendPrintf("%.2X", hash.complete.buf[i]);
}
return hex;
--- a/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp
+++ b/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp
@@ -1092,20 +1092,17 @@ nsUrlClassifierLookupCallback::LookupCom
// complete.
if ((!gethashUrl.IsEmpty() ||
StringBeginsWith(result.mTableName, NS_LITERAL_CSTRING("test"))) &&
mDBService->GetCompleter(result.mTableName,
getter_AddRefs(completer))) {
// Bug 1323953 - Send the first 4 bytes for completion no matter how
// long we matched the prefix.
- nsAutoCString partialHash;
- partialHash.Assign(reinterpret_cast<char*>(&result.hash.fixedLengthPrefix),
- PREFIX_SIZE);
- nsresult rv = completer->Complete(partialHash,
+ nsresult rv = completer->Complete(result.PartialHash(),
gethashUrl,
result.mTableName,
this);
if (NS_SUCCEEDED(rv)) {
mPendingCompletions++;
}
} else {
// For tables with no hash completer, a complete hash match is