Fix memory leaks

This commit is contained in:
Svetlana Kulikova
2024-07-29 17:56:48 +03:00
parent 0eb8c93cf9
commit 16ae48ef4e
8 changed files with 11 additions and 5 deletions

View File

@ -95,6 +95,7 @@ CPdfFile::~CPdfFile()
RELEASEOBJECT(m_pInternal->pWriter);
RELEASEOBJECT(m_pInternal->pReader);
RELEASEOBJECT(m_pInternal->pEditor);
RELEASEOBJECT(m_pInternal);
}
NSFonts::IFontManager* CPdfFile::GetFontManager()
{

View File

@ -614,7 +614,6 @@ std::wstring CPdfReader::GetInfo()
std::wstring sRes = L"{";
Object oInfo;
m_pPDFDocument->getDocInfo(&oInfo);
if (m_pPDFDocument->getDocInfo(&oInfo)->isDict())
{
auto fDictLookup = [&oInfo](const char* sName, const wchar_t* wsName)
@ -953,6 +952,7 @@ BYTE* CPdfReader::GetLinks(int nPageIndex)
if (!sLink)
continue;
std::string link(sLink->getCString(), sLink->getLength());
RELEASEOBJECT(sLink);
size_t find = link.find("http://");
if (find == std::string::npos)
find = link.find("https://");
@ -966,6 +966,7 @@ BYTE* CPdfReader::GetLinks(int nPageIndex)
oLinks.m_arLinks.push_back({link, 0, x1, y1, x2 - x1, y2 - y1});
}
}
RELEASEOBJECT(pWordList);
RELEASEOBJECT(pTextOut);
return oLinks.Serialize();

View File

@ -34,7 +34,6 @@
#include "../lib/xpdf/TextString.h"
#include "../../DesktopEditor/graphics/pro/js/wasm/src/serialize.h"
void GlobalParamsAdaptor::SetFontManager(NSFonts::IFontManager *pFontManager)
{
m_pFontManager = pFontManager;

View File

@ -37,6 +37,7 @@
#include <string>
#include <math.h>
#include "../lib/xpdf/GfxState.h"
#include "../../DesktopEditor/common/Types.h"
#include "MemoryUtils.h"
struct GfxClipMatrix
@ -351,6 +352,8 @@ public:
~GfxClip()
{
delete m_pTextClip;
for (int i = 0; i < m_vPaths.size(); ++i)
RELEASEOBJECT(m_vPaths[i]);
}
void AddPath(GfxPath *pPath, double *Matrix, bool bEo)

View File

@ -2439,6 +2439,7 @@ void CAnnots::getParents(XRef* xref, Object* oFieldRef)
TextString* s = new TextString(oOptJ.getString());
pAnnotParent->arrOpt.push_back(NSStringExt::CConverter::GetUtf8FromUTF32(s->getUnicode(), s->getLength()));
delete s;
oOptJ.free();
}
if (!pAnnotParent->arrOpt.empty())
pAnnotParent->unFlags |= (1 << 6);
@ -2455,6 +2456,8 @@ void CAnnots::getParents(XRef* xref, Object* oFieldRef)
getParents(xref, &oParentRefObj);
}
oParentRefObj.free();
oField.free();
}
//------------------------------------------------------------------------