summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/fpdfedit_embeddertest.cpp8
-rw-r--r--fpdfsdk/fpdfeditpage.cpp4
-rw-r--r--fpdfsdk/fpdfview_c_api_test.c1
3 files changed, 13 insertions, 0 deletions
diff --git a/fpdfsdk/fpdfedit_embeddertest.cpp b/fpdfsdk/fpdfedit_embeddertest.cpp
index f1bbb87422..c381b25efa 100644
--- a/fpdfsdk/fpdfedit_embeddertest.cpp
+++ b/fpdfsdk/fpdfedit_embeddertest.cpp
@@ -1030,3 +1030,11 @@ TEST_F(FPDFEditEmbeddertest, GetImageData) {
UnloadPage(page);
}
+
+TEST_F(FPDFEditEmbeddertest, DestroyPageObject) {
+ FPDF_PAGEOBJECT rect = FPDFPageObj_CreateNewRect(10, 10, 20, 20);
+ ASSERT_TRUE(rect);
+
+ // There should be no memory leaks with a call to FPDFPageObj_Destroy().
+ FPDFPageObj_Destroy(rect);
+}
diff --git a/fpdfsdk/fpdfeditpage.cpp b/fpdfsdk/fpdfeditpage.cpp
index a7ee212aee..91b966c384 100644
--- a/fpdfsdk/fpdfeditpage.cpp
+++ b/fpdfsdk/fpdfeditpage.cpp
@@ -201,6 +201,10 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFPage_HasTransparency(FPDF_PAGE page) {
return pPage && pPage->BackgroundAlphaNeeded();
}
+DLLEXPORT void STDCALL FPDFPageObj_Destroy(FPDF_PAGEOBJECT page_obj) {
+ delete CPDFPageObjectFromFPDFPageObject(page_obj);
+}
+
DLLEXPORT FPDF_BOOL STDCALL
FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT pageObject) {
if (!pageObject)
diff --git a/fpdfsdk/fpdfview_c_api_test.c b/fpdfsdk/fpdfview_c_api_test.c
index d40437c278..ef5b804baa 100644
--- a/fpdfsdk/fpdfview_c_api_test.c
+++ b/fpdfsdk/fpdfview_c_api_test.c
@@ -121,6 +121,7 @@ int CheckPDFiumCApi() {
CHK(FPDFPage_GetObject);
CHK(FPDFPage_HasTransparency);
CHK(FPDFPage_GenerateContent);
+ CHK(FPDFPageObj_Destroy);
CHK(FPDFPageObj_HasTransparency);
CHK(FPDFPageObj_GetBounds);
CHK(FPDFPageObj_GetType);