1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:07:34 +00:00

LibPDF: Convert PDF::Parser::m_document from RefPtr to WeakPtr

Otherwise both `PDF::Document` and `PDF::Parser` have a `RefPtr`
pointing to each other which leads to a memory leak due to a circular
dependency.
This commit is contained in:
Simon Woertz 2021-11-28 11:52:48 +01:00 committed by Linus Groh
parent d8013f9c3a
commit c857b5d22f
3 changed files with 8 additions and 4 deletions

View file

@ -7,6 +7,7 @@
#pragma once
#include <AK/NonnullRefPtrVector.h>
#include <AK/WeakPtr.h>
#include <LibPDF/Command.h>
#include <LibPDF/Object.h>
#include <LibPDF/Reader.h>
@ -29,7 +30,7 @@ public:
Parser(Badge<Document>, ReadonlyBytes);
[[nodiscard]] ALWAYS_INLINE RefPtr<DictObject> const& trailer() const { return m_trailer; }
void set_document(RefPtr<Document> const&);
void set_document(WeakPtr<Document> const&);
// Parses the header and initializes the xref table and trailer
bool initialize();
@ -139,7 +140,7 @@ private:
bool consume(char);
Reader m_reader;
RefPtr<Document> m_document;
WeakPtr<Document> m_document;
RefPtr<XRefTable> m_xref_table;
RefPtr<DictObject> m_trailer;
Optional<LinearizationDictionary> m_linearization_dictionary;