From 4909ab1a70bf5dcf7204193a975c6ad8e11403fa Mon Sep 17 00:00:00 2001 From: Thomas Nguyen Date: Wed, 5 Jul 2017 17:21:01 +0800 Subject: [PATCH] Bug 1363882 - Remove casting address of inactive member union result.hash r=francois MozReview-Commit-ID: 3pVaVJ1EJZu --HG-- extra : rebase_source : 6549a5f1d303363cfb472753c3fe256c3d1dd740 --- toolkit/components/url-classifier/LookupCache.h | 8 +++++++- .../url-classifier/nsUrlClassifierDBService.cpp | 5 +---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/toolkit/components/url-classifier/LookupCache.h b/toolkit/components/url-classifier/LookupCache.h index 139bb4cc47a9..5bca76d08178 100644 --- a/toolkit/components/url-classifier/LookupCache.h +++ b/toolkit/components/url-classifier/LookupCache.h @@ -44,7 +44,13 @@ public: nsCString PartialHash() { MOZ_ASSERT(mPartialHashLength <= COMPLETE_SIZE); - return nsCString(reinterpret_cast(hash.complete.buf), mPartialHashLength); + if (mNoise) { + return nsCString(reinterpret_cast(hash.fixedLengthPrefix.buf), + PREFIX_SIZE); + } else { + return nsCString(reinterpret_cast(hash.complete.buf), + mPartialHashLength); + } } nsCString PartialHashHex() { diff --git a/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp b/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp index 9a395eba5090..6481469c40e6 100644 --- a/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp +++ b/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp @@ -1097,10 +1097,7 @@ nsUrlClassifierLookupCallback::LookupComplete(nsTArray* results) // Bug 1323953 - Send the first 4 bytes for completion no matter how // long we matched the prefix. - nsAutoCString partialHash; - partialHash.Assign(reinterpret_cast(&result.hash.fixedLengthPrefix), - PREFIX_SIZE); - nsresult rv = completer->Complete(partialHash, + nsresult rv = completer->Complete(result.PartialHash(), gethashUrl, result.mTableName, this);