Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Issue 2631703003: Avoid endless loop deleting CFGAS_GEFont. (Closed)

Created:
3 years, 11 months ago by Tom Sepez
Modified:
3 years, 11 months ago
Reviewers:
dsinclair, npm
CC:
pdfium-reviews_googlegroups.com
Target Ref:
refs/heads/master
Project:
pdfium
Visibility:
Public.

Description

Avoid endless loop deleting CFGAS_GEFont. It's a ref-counted class, so if we're in the destructor, the ref count has hit zero. We can't make a new ref pointer to itself here, as it will re-invoke the destructor when it goes out of scope. This should have been an obvious anti-pattern in hindsight. The object in question can't be in the m_pFontManager, since the font manager retains a reference, and we wouldn't get to this destructor while that is present. So the cleanup isn't required. Fixing this revealed a free-delete mismatch in cxfa_textlayout.cpp. I also converted to use unique_ptrs in a few places near this issue. Fixing this revealed a UAF in CFGAS_GEFont, memcpy'ing a RetainPtr is not a good idea as it doesn't bump the ref count. Also protect and friend the CFGAS_GEFont destructor, to make sure random deletes don't happen. Also kill off a const cast, and remove unnecessary conversion to retain_ptr when we already have one. TEST=look for absence of -11 in XFA corpus test logs, bots not currently noticing the segv. Argh. Review-Url: https://codereview.chromium.org/2631703003 Committed: https://pdfium.googlesource.com/pdfium/+/783a7e048c677d26aaf3884304627bbe27cff546

Patch Set 1 #

Total comments: 1

Patch Set 2 : rebase #

Unified diffs Side-by-side diffs Delta from patch set Stats (+75 lines, -97 lines) Patch
M core/fxcrt/cfx_retain_ptr.h View 1 chunk +1 line, -0 lines 0 comments Download
M xfa/fde/cfde_txtedtengine.cpp View 1 chunk +1 line, -1 line 0 comments Download
M xfa/fgas/font/cfgas_gefont.h View 1 4 chunks +4 lines, -3 lines 0 comments Download
M xfa/fgas/font/cfgas_gefont.cpp View 3 chunks +3 lines, -8 lines 0 comments Download
M xfa/fxfa/app/cxfa_pieceline.h View 2 chunks +4 lines, -1 line 0 comments Download
M xfa/fxfa/app/cxfa_pieceline.cpp View 1 chunk +2 lines, -0 lines 0 comments Download
M xfa/fxfa/app/cxfa_textlayout.h View 1 4 chunks +7 lines, -4 lines 0 comments Download
M xfa/fxfa/app/cxfa_textlayout.cpp View 1 17 chunks +41 lines, -66 lines 0 comments Download
M xfa/fxfa/app/xfa_fftext.cpp View 1 chunk +8 lines, -13 lines 0 comments Download
M xfa/fxfa/app/xfa_textpiece.cpp View 1 chunk +4 lines, -1 line 0 comments Download

Messages

Total messages: 25 (16 generated)
Tom Sepez
Dan, npm, ready for review.
3 years, 11 months ago (2017-01-14 01:43:41 UTC) #6
dsinclair
lgtm
3 years, 11 months ago (2017-01-16 21:47:35 UTC) #13
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2631703003/1
3 years, 11 months ago (2017-01-16 21:47:37 UTC) #14
commit-bot: I haz the power
Try jobs failed on following builders: android on master.tryserver.client.pdfium (JOB_FAILED, https://build.chromium.org/p/tryserver.client.pdfium/builders/android/builds/2076)
3 years, 11 months ago (2017-01-16 21:48:47 UTC) #16
npm
lgtm https://codereview.chromium.org/2631703003/diff/1/xfa/fxfa/app/cxfa_pieceline.cpp File xfa/fxfa/app/cxfa_pieceline.cpp (right): https://codereview.chromium.org/2631703003/diff/1/xfa/fxfa/app/cxfa_pieceline.cpp#newcode9 xfa/fxfa/app/cxfa_pieceline.cpp:9: #include "xfa/fxfa/app/xfa_textpiece.h" Why is this now needed?
3 years, 11 months ago (2017-01-16 22:24:34 UTC) #17
Tom Sepez
On 2017/01/16 22:24:34, npm wrote: > lgtm > > https://codereview.chromium.org/2631703003/diff/1/xfa/fxfa/app/cxfa_pieceline.cpp > File xfa/fxfa/app/cxfa_pieceline.cpp (right): > ...
3 years, 11 months ago (2017-01-17 18:43:16 UTC) #18
Tom Sepez
3 years, 11 months ago (2017-01-17 18:49:18 UTC) #19
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2631703003/20001
3 years, 11 months ago (2017-01-17 18:50:09 UTC) #22
commit-bot: I haz the power
3 years, 11 months ago (2017-01-17 19:06:02 UTC) #25
Message was sent while issue was closed.
Committed patchset #2 (id:20001) as
https://pdfium.googlesource.com/pdfium/+/783a7e048c677d26aaf3884304627bbe27cf...

Powered by Google App Engine
This is Rietveld 408576698