Jelajahi Sumber

LibPDF: Eliminate reference cycle between OutlineItem parent/children

Since all parents held a reference pointer to their children, and all
children held reference pointers to their parents, both objects would
never get free'd once the document was no longer being used.

Fixes ossfuzz-63833.
Idan Horowitz 1 tahun lalu
induk
melakukan
aad5c58996
1 mengubah file dengan 3 tambahan dan 2 penghapusan
  1. 3 2
      Userland/Libraries/LibPDF/Document.h

+ 3 - 2
Userland/Libraries/LibPDF/Document.h

@@ -36,8 +36,9 @@ struct Destination {
     Vector<Optional<float>> parameters;
 };
 
-struct OutlineItem final : public RefCounted<OutlineItem> {
-    RefPtr<OutlineItem> parent;
+struct OutlineItem final : public RefCounted<OutlineItem>
+    , public Weakable<OutlineItem> {
+    WeakPtr<OutlineItem> parent;
     Vector<NonnullRefPtr<OutlineItem>> children;
     DeprecatedString title; // Already converted to UTF-8.
     i32 count { 0 };