summaryrefslogtreecommitdiff
path: root/fpdfsdk/pwl/cpwl_edit.cpp
diff options
context:
space:
mode:
authorHenrique Nakashima <hnakashima@chromium.org>2017-10-04 11:08:45 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-10-04 16:02:44 +0000
commit55469aed5acffcce3259d37418ba9e8b8e60d801 (patch)
treefbee70533185e962adebb082dfa587e80c325873 /fpdfsdk/pwl/cpwl_edit.cpp
parenta5fc8975c865dc3cc90de8ff46ca13fb46c13391 (diff)
downloadpdfium-55469aed5acffcce3259d37418ba9e8b8e60d801.tar.xz
Fix UAF in SetVisible().
SetVisible() may be called during Destroy() which may be called during SetVisible(). This fixes the latest in a family of bugs that happen after an instance is freed by code triggered by JS code while it's executing a method. The CL has a lot of protection for many of these points where JS may be executed and potentially destroy objects. The return types of many methods that may execute JS have been changed to bool, indicating whether the instance is still alive after the call. Bug: chromium:770148 Change-Id: If5a9db4d8d6aac10f4dd6b645922bb96c116684d Reviewed-on: https://pdfium-review.googlesource.com/15190 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'fpdfsdk/pwl/cpwl_edit.cpp')
-rw-r--r--fpdfsdk/pwl/cpwl_edit.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/fpdfsdk/pwl/cpwl_edit.cpp b/fpdfsdk/pwl/cpwl_edit.cpp
index 662c69e369..650db5438b 100644
--- a/fpdfsdk/pwl/cpwl_edit.cpp
+++ b/fpdfsdk/pwl/cpwl_edit.cpp
@@ -79,13 +79,18 @@ void CPWL_Edit::SetText(const WideString& csText) {
m_pEdit->SetText(swText);
}
-void CPWL_Edit::RePosChildWnd() {
+bool CPWL_Edit::RePosChildWnd() {
if (CPWL_ScrollBar* pVSB = GetVScrollBar()) {
CFX_FloatRect rcWindow = m_rcOldWindow;
CFX_FloatRect rcVScroll =
CFX_FloatRect(rcWindow.right, rcWindow.bottom,
rcWindow.right + PWL_SCROLLBAR_WIDTH, rcWindow.top);
+
+ ObservedPtr thisObserved(this);
+
pVSB->Move(rcVScroll, true, false);
+ if (!thisObserved)
+ return false;
}
if (m_pEditCaret && !HasFlag(PES_TEXTOVERFLOW)) {
@@ -98,7 +103,7 @@ void CPWL_Edit::RePosChildWnd() {
m_pEditCaret->SetClipRect(rect);
}
- CPWL_EditCtrl::RePosChildWnd();
+ return CPWL_EditCtrl::RePosChildWnd();
}
CFX_FloatRect CPWL_Edit::GetClientRect() const {
@@ -290,8 +295,8 @@ bool CPWL_Edit::OnLButtonDown(const CFX_PointF& point, uint32_t nFlag) {
CPWL_Wnd::OnLButtonDown(point, nFlag);
if (HasFlag(PES_TEXTOVERFLOW) || ClientHitTest(point)) {
- if (m_bMouseDown)
- InvalidateRect(nullptr);
+ if (m_bMouseDown && !InvalidateRect(nullptr))
+ return true;
m_bMouseDown = true;
SetCapture();
@@ -355,17 +360,15 @@ void CPWL_Edit::OnKillFocus() {
if (!observed_ptr)
return;
- Move(m_rcOldWindow, true, true);
+ if (!Move(m_rcOldWindow, true, true))
+ return;
}
- if (!observed_ptr)
- return;
m_pEdit->SelectNone();
if (!observed_ptr)
return;
- SetCaret(false, CFX_PointF(), CFX_PointF());
- if (!observed_ptr)
+ if (!SetCaret(false, CFX_PointF(), CFX_PointF()))
return;
SetCharSet(FX_CHARSET_ANSI);