Commit 0fdfc2b2 authored by Aleks Totic's avatar Aleks Totic Committed by Commit Bot

[LayoutNG] Fix Heap-use-after-free in GetDocument

The fix is not to allow paint fragment traversal if layout is
dirty. The traversal was triggered by:

NGPaintFragment::SetShouldDoFullPaintInvalidationForFirstLine

There were other methods doing unsafe paint fragment traversals,
and this will prevent all of them from traversing a dirty
layout tree.

Bug: 962141
Change-Id: I2b44a2cdb250f26f654e108787477f2190a35658
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1612219Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Commit-Queue: Aleks Totic <atotic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#659675}
parent b2a788c9
...@@ -52,7 +52,13 @@ class LayoutNGMixin : public Base { ...@@ -52,7 +52,13 @@ class LayoutNGMixin : public Base {
PositionWithAffinity PositionForPoint(const LayoutPoint&) const final; PositionWithAffinity PositionForPoint(const LayoutPoint&) const final;
NGPaintFragment* PaintFragment() const final { return paint_fragment_.get(); } NGPaintFragment* PaintFragment() const final {
// TODO(layout-dev) crbug.com/963103
// Safer option here is to return nullptr only if
// Lifecycle > DocumentLifecycle::kAfterPerformLayout, but this breaks
// some layout tests.
return Base::NeedsLayout() ? nullptr : paint_fragment_.get();
}
void SetPaintFragment(const NGBlockBreakToken*, void SetPaintFragment(const NGBlockBreakToken*,
scoped_refptr<const NGPhysicalFragment>) final; scoped_refptr<const NGPhysicalFragment>) final;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment