Don't try to free unallocated things when releasing the PdfDocument object.

[GB.POPPLER]
* BUG: Don't try to free unallocated things when releasing the PdfDocument object.
This commit is contained in:
Benoît Minisini 2022-12-31 16:50:08 +01:00
parent ca6ce92d1e
commit 5181dc1427

View file

@ -133,29 +133,32 @@ BEGIN_METHOD_VOID(PdfDocument_free)
int i; int i;
if (THIS->pages) if (THIS->doc)
{ {
for (i = 0; i < poppler_document_get_n_pages(THIS->doc); i++) if (THIS->pages)
{ {
if (THIS->pages[i]) for (i = 0; i < poppler_document_get_n_pages(THIS->doc); i++)
g_object_unref(THIS->pages[i]); {
if (THIS->pages[i])
g_object_unref(THIS->pages[i]);
}
GB.Free(POINTER(&THIS->pages));
} }
GB.Free(POINTER(&THIS->pages)); if (THIS->index)
{
for (i = 0; i < GB.Count(THIS->index); i++)
GB.Unref(POINTER(&THIS->index[i]));
GB.FreeArray(POINTER(&THIS->index));
}
delete THIS->renderer;
delete THIS->rdoc;
g_object_unref(THIS->doc);
} }
if (THIS->index)
{
for (i = 0; i < GB.Count(THIS->index); i++)
GB.Unref(POINTER(&THIS->index[i]));
GB.FreeArray(POINTER(&THIS->index));
}
delete THIS->renderer;
delete THIS->rdoc;
g_object_unref(THIS->doc);
GB.ReleaseFile(THIS->buffer, THIS->length); GB.ReleaseFile(THIS->buffer, THIS->length);
END_METHOD END_METHOD