Hi all,
I'd like to fix this function implementation, as it makes my eyes cry ;)
Notice that if pFrame == NULL, the function will crash anyway because
it's only checked in the first if block and later is dereferenced.
static void ImplHandleInputLangChange( HWND hWnd, WPARAM, LPARAM lParam )
{
ImplSalYieldMutexAcquireWithWait();
// Feststellen, ob wir IME unterstuetzen
WinSalFrame* pFrame = GetWindowPtr( hWnd );
if ( pFrame && pFrame->mbIME && pFrame->mhDefIMEContext )
{
HKL hKL = (HKL)lParam;
UINT nImeProps = ImmGetProperty( hKL, IGP_PROPERTY );
pFrame->mbSpezIME = (nImeProps & IME_PROP_SPECIAL_UI) != 0;
pFrame->mbAtCursorIME = (nImeProps & IME_PROP_AT_CARET) != 0;
pFrame->mbHandleIME = !pFrame->mbSpezIME;
}
// trigger input language and codepage update
UINT nLang = pFrame->mnInputLang;
ImplUpdateInputLang( pFrame );
// notify change
if( nLang != pFrame->mnInputLang )
pFrame->CallCallback( SALEVENT_INPUTLANGUAGECHANGE, 0 );
ImplSalYieldMutexRelease();
}
What's the preferred way to fix it?
a) put everything in an if (pFrame) {....} block
b) if(!pFrame) return;
Thanks for the help! :)
--
Jesús Corrius <jesus@softcatala.org>
Document Foundation founding member
Mobile: +34 661 11 38 26
Skype: jcorrius | Twitter: @jcorrius
Context
- [Libreoffice] Help fixing ImplHandleInputLangChange implementation · Jesús Corrius
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.