Bug 1774317 - part 3: Fix forgotten member initializing of TSFTextStore r=m_kato

The crash tracked in bug 1792767 is caused by uninitialized member of
`TSFTextStore`.  Therefore, it runs the cleaning up the TSF objects at
setting focus to new `TSFTextStore`, but MS-IME didn't grab the necessary
objects and thus, the crash occurs.

Differential Revision: https://phabricator.services.mozilla.com/D158311
This commit is contained in:
Masayuki Nakano 2022-09-29 14:06:03 +00:00
parent 725ca35ef4
commit ea14dc51d0
2 changed files with 9 additions and 10 deletions

View file

@ -28,7 +28,6 @@
#include "mozilla/WindowsVersion.h"
#include "nsWindow.h"
#include "nsPrintfCString.h"
#include "nsReadableUtils.h" // for VoidString()
// Workaround for mingw32
#ifndef TS_SD_INPUTPANEMANUALDISPLAYENABLE
@ -4097,13 +4096,13 @@ TSFTextStore::RetrieveRequestedAttrs(ULONG ulCount, TS_ATTRVAL* paAttrVals,
StaticPrefs::intl_tsf_expose_url_allowed() &&
(!mInPrivateBrowsing ||
StaticPrefs::intl_tsf_expose_url_in_private_browsing_allowed());
if (!allowed) {
MOZ_ASSERT(EmptyString().get());
return ::SysAllocString(EmptyString().get());
}
if (mDocumentURL.IsEmpty()) {
MOZ_ASSERT(EmptyString().get());
return ::SysAllocString(EmptyString().get());
if (!allowed || mDocumentURL.IsEmpty()) {
BSTR emptyString = ::SysAllocString(L"");
MOZ_ASSERT(
emptyString,
"We need to return valid BSTR pointer to notify TSF of supporting it "
"with a pointer to empty string");
return emptyString;
}
return ::SysAllocString(mDocumentURL.get());
};

View file

@ -1035,7 +1035,7 @@ class TSFTextStore final : public ITextStoreACP,
// Count of the supported attributes
NUM_OF_SUPPORTED_ATTRS
};
bool mRequestedAttrs[NUM_OF_SUPPORTED_ATTRS]{false};
bool mRequestedAttrs[NUM_OF_SUPPORTED_ATTRS] = {false};
int32_t GetRequestedAttrIndex(const TS_ATTRID& aAttrID);
TS_ATTRID GetAttrID(int32_t aIndex);
@ -1056,7 +1056,7 @@ class TSFTextStore final : public ITextStoreACP,
bool mWaitingQueryLayout = false;
// During the document is locked, we shouldn't destroy the instance.
// If this is true, the instance will be destroyed after unlocked.
bool mPendingDestroy;
bool mPendingDestroy = false;
// If this is false, MaybeFlushPendingNotifications() will clear the
// mContentForTSF.
bool mDeferClearingContentForTSF = false;