From 5d7726e3f18a457b2e7cec68a308cbede6520fae Mon Sep 17 00:00:00 2001 From: Ilya Ivanov Date: Thu, 27 Apr 2017 15:06:56 +0300 Subject: [PATCH 1/4] Fix check for wxACC_STATE_SYSTEM_MARQUEED in accessibility code wxACC_STATE_SYSTEM_INVISIBLE was checked twice, by mistake, while wxACC_STATE_SYSTEM_MARQUEED was never checked at all. Thanks to PVS-Studio for finding this issue (V581: The conditional expressions of the 'if' operators situated alongside each other are identical). --- src/msw/ole/access.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/msw/ole/access.cpp b/src/msw/ole/access.cpp index fd06b3043f..7c5d3541d5 100644 --- a/src/msw/ole/access.cpp +++ b/src/msw/ole/access.cpp @@ -2037,8 +2037,8 @@ long wxConvertToWindowsState(long wxstate) if (wxstate & wxACC_STATE_SYSTEM_INVISIBLE) state |= STATE_SYSTEM_INVISIBLE; - if (wxstate & wxACC_STATE_SYSTEM_INVISIBLE) - state |= STATE_SYSTEM_INVISIBLE; + if (wxstate & wxACC_STATE_SYSTEM_MARQUEED) + state |= STATE_SYSTEM_MARQUEED; if (wxstate & wxACC_STATE_SYSTEM_MIXED) state |= STATE_SYSTEM_MIXED; From b65a3ad736da6068fffabf4642b7fd5df12fa733 Mon Sep 17 00:00:00 2001 From: Ilya Ivanov Date: Thu, 27 Apr 2017 15:06:56 +0300 Subject: [PATCH 2/4] Use VARIANT_TRUE and VARIANT_FALSE correctly VARIANT_TRUE (-1) must be used with VARIANTs of boolean type, instead of TRUE (1) which has a different value and can result in interoperability problems. Thanks to PVS-Studio for finding this issue (V721 The VARIANT_BOOL type is utilized incorrectly). --- src/msw/ole/activex.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/msw/ole/activex.cpp b/src/msw/ole/activex.cpp index 9fd00b1133..83bcc429ad 100644 --- a/src/msw/ole/activex.cpp +++ b/src/msw/ole/activex.cpp @@ -251,24 +251,24 @@ public: switch (dispIdMember) { case DISPID_AMBIENT_MESSAGEREFLECT: - V_BOOL(pVarResult)= FALSE; + V_BOOL(pVarResult)= VARIANT_FALSE; return S_OK; case DISPID_AMBIENT_DISPLAYASDEFAULT: - V_BOOL(pVarResult)= TRUE; + V_BOOL(pVarResult)= VARIANT_TRUE; return S_OK; case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED: - V_BOOL(pVarResult) = TRUE; + V_BOOL(pVarResult) = VARIANT_TRUE; return S_OK; case DISPID_AMBIENT_SILENT: - V_BOOL(pVarResult)= TRUE; + V_BOOL(pVarResult)= VARIANT_TRUE; return S_OK; case DISPID_AMBIENT_APPEARANCE: pVarResult->vt = VT_BOOL; - pVarResult->boolVal = m_bAmbientAppearance; + pVarResult->boolVal = m_bAmbientAppearance ? VARIANT_TRUE : VARIANT_FALSE; break; case DISPID_AMBIENT_FORECOLOR: @@ -288,17 +288,17 @@ public: case DISPID_AMBIENT_USERMODE: pVarResult->vt = VT_BOOL; - pVarResult->boolVal = m_window->m_bAmbientUserMode; + pVarResult->boolVal = m_window->m_bAmbientUserMode ? VARIANT_TRUE : VARIANT_FALSE; break; case DISPID_AMBIENT_SHOWGRABHANDLES: pVarResult->vt = VT_BOOL; - pVarResult->boolVal = m_bAmbientShowGrabHandles; + pVarResult->boolVal = m_bAmbientShowGrabHandles ? VARIANT_TRUE : VARIANT_FALSE; break; case DISPID_AMBIENT_SHOWHATCHING: pVarResult->vt = VT_BOOL; - pVarResult->boolVal = m_bAmbientShowHatching; + pVarResult->boolVal = m_bAmbientShowHatching ? VARIANT_TRUE : VARIANT_FALSE; break; default: From ab7c39fddb1627f593483075ed05165a42f26db0 Mon Sep 17 00:00:00 2001 From: Ilya Ivanov Date: Thu, 27 Apr 2017 15:06:56 +0300 Subject: [PATCH 3/4] Check for variable being non-NULL before using it The "buffer" argument can apparently be null, as there is a check for this on the next line, but it was used without checking that this is the case. Fix this, although it's not totally clear if "buffer" can really be null at all and maybe the check below should have been removed instead -- but prefer to err on the side of caution. Thanks to PVS-Studio for finding this issue (V595 The 'buffer' pointer was utilized before it was verified against nullptr). --- src/richtext/richtextbuffer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/richtext/richtextbuffer.cpp b/src/richtext/richtextbuffer.cpp index 8f17c6a430..a9e14037fb 100644 --- a/src/richtext/richtextbuffer.cpp +++ b/src/richtext/richtextbuffer.cpp @@ -9932,7 +9932,7 @@ bool wxRichTextCell::EditProperties(wxWindow* parent, wxRichTextBuffer* buffer) wxRichTextAttr attr; wxRichTextSelection sel; - if (buffer->GetRichTextCtrl()) + if (buffer && buffer->GetRichTextCtrl()) sel = buffer->GetRichTextCtrl()->GetSelection(); if (table && buffer && buffer->GetRichTextCtrl() && sel.IsValid() && From 6697a7e49a0c0fe91fd3a5a9eb714d84e3c5b2e6 Mon Sep 17 00:00:00 2001 From: Ilya Ivanov Date: Thu, 27 Apr 2017 15:06:56 +0300 Subject: [PATCH 4/4] Fix wrong variable name in assignment in wxRichTextSizePage dtor The "sm_showMinMaxSizeControls" was assigned twice, while "sm_enablePositionAndSizeUnits" was not assigned at all, apparently by mistake. Thanks to PVS-Studio for finding this issue (V519 The 'sm_showMinMaxSizeControls' variable is assigned values twice successively). --- src/richtext/richtextsizepage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/richtext/richtextsizepage.cpp b/src/richtext/richtextsizepage.cpp index 585c88e4da..7ace91a0bb 100644 --- a/src/richtext/richtextsizepage.cpp +++ b/src/richtext/richtextsizepage.cpp @@ -116,7 +116,7 @@ wxRichTextSizePage::~wxRichTextSizePage() sm_showAlignmentControls = true; sm_showFloatingAndAlignmentControls = true; sm_showMinMaxSizeControls = true; - sm_showMinMaxSizeControls = true; + sm_enablePositionAndSizeUnits = true; sm_enablePositionAndSizeCheckboxes = true; sm_showMoveObjectControls = true;