Remove Release() from CPDF_PageObject

BUG=pdfium:140
R=thestig@chromium.org

Review URL: https://codereview.chromium.org/1093213002
diff --git a/core/include/fpdfapi/fpdf_pageobj.h b/core/include/fpdfapi/fpdf_pageobj.h
index bd11a20..e78c9bb 100644
--- a/core/include/fpdfapi/fpdf_pageobj.h
+++ b/core/include/fpdfapi/fpdf_pageobj.h
@@ -455,10 +455,8 @@
 class CPDF_PageObject : public CPDF_GraphicStates
 {
 public:
-
     static CPDF_PageObject* Create(int type);
-
-    void				Release();
+    virtual ~CPDF_PageObject();
 
     CPDF_PageObject*	Clone() const;
 
@@ -505,7 +503,6 @@
 
     CPDF_PageObject() {}
 
-    virtual ~CPDF_PageObject() {}
 };
 struct CPDF_TextObjectItem  {
 
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
index 998bc27..4ec753d 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
@@ -7,10 +7,6 @@
 #include "../../../include/fpdfapi/fpdf_page.h"
 #include "../../../include/fpdfapi/fpdf_module.h"
 #include "pageint.h"
-void CPDF_PageObject::Release()
-{
-    delete this;
-}
 CPDF_PageObject* CPDF_PageObject::Create(int type)
 {
     switch (type) {
@@ -27,6 +23,9 @@
     }
     return NULL;
 }
+CPDF_PageObject::~CPDF_PageObject()
+{
+}
 CPDF_PageObject* CPDF_PageObject::Clone() const
 {
     CPDF_PageObject* pObj = Create(m_Type);
@@ -689,11 +688,7 @@
     }
     FX_POSITION pos = m_ObjectList.GetHeadPosition();
     while (pos) {
-        CPDF_PageObject* pPageObj = (CPDF_PageObject*)m_ObjectList.GetNext(pos);
-        if (!pPageObj) {
-            continue;
-        }
-        pPageObj->Release();
+        delete (CPDF_PageObject*)m_ObjectList.GetNext(pos);
     }
 }
 void CPDF_PageObjects::ContinueParse(IFX_Pause* pPause)
@@ -808,11 +803,7 @@
     if (m_bReleaseMembers) {
         FX_POSITION pos = m_ObjectList.GetHeadPosition();
         while (pos) {
-            CPDF_PageObject* pPageObj = (CPDF_PageObject*)m_ObjectList.GetNext(pos);
-            if (!pPageObj) {
-                continue;
-            }
-            pPageObj->Release();
+            delete (CPDF_PageObject*)m_ObjectList.GetNext(pos);
         }
     }
     m_ObjectList.RemoveAll();
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp
index 40ec13e..f79fcda 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp
@@ -192,8 +192,7 @@
     CPDF_ClipPathData* pData = GetModify();
     if (pData->m_TextCount + count > FPDF_CLIPPATH_MAX_TEXTS) {
         for (int i = 0; i < count; i ++) {
-            if (pTexts[i])
-                pTexts[i]->Release();
+            delete pTexts[i];
         }
         return;
     }
diff --git a/core/src/fpdfdoc/doc_annot.cpp b/core/src/fpdfdoc/doc_annot.cpp
index cc6b5cc..4ccce21 100644
--- a/core/src/fpdfdoc/doc_annot.cpp
+++ b/core/src/fpdfdoc/doc_annot.cpp
@@ -4,8 +4,10 @@
  
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
+#include "../../../third_party/base/nonstd_unique_ptr.h"
 #include "../../include/fpdfdoc/fpdf_doc.h"
 #include "../../include/fpdfapi/fpdf_pageobj.h"
+
 CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage)
 {
     ASSERT(pPage != NULL);
@@ -317,16 +319,14 @@
         int B = (FX_INT32)(pColor->GetNumber(2) * 255);
         argb = ArgbEncode(0xff, R, G, B);
     }
-    CPDF_PathObject *pPathObject = new CPDF_PathObject();
+    nonstd::unique_ptr<CPDF_PathObject> pPathObject(new CPDF_PathObject());
     CPDF_GraphStateData *pGraphState = pPathObject->m_GraphState.GetModify();
     if (!pGraphState) {
-        pPathObject->Release();
         return NULL;
     }
     pGraphState->m_LineWidth = width;
     CPDF_ColorStateData *pColorData = pPathObject->m_ColorState.GetModify();
     if (!pColorData) {
-        pPathObject->Release();
         return NULL;
     }
     pColorData->m_StrokeRGB = argb;
@@ -340,7 +340,6 @@
             }
             pGraphState->m_DashArray = FX_Alloc(FX_FLOAT, dash_count);
             if (pGraphState->m_DashArray == NULL) {
-                pPathObject->Release();
                 return NULL;
             }
             pGraphState->m_DashCount = dash_count;
@@ -354,7 +353,6 @@
         } else {
             pGraphState->m_DashArray = FX_Alloc(FX_FLOAT, 2);
             if (pGraphState->m_DashArray == NULL) {
-                pPathObject->Release();
                 return NULL;
             }
             pGraphState->m_DashCount = 2;
@@ -369,7 +367,7 @@
         pPathData->AppendRect(rect.left + width, rect.bottom + width, rect.right - width, rect.top - width);
     }
     pPathObject->CalcBoundingBox();
-    return pPathObject;
+    return pPathObject.release();
 }
 void CPDF_Annot::DrawBorder(CFX_RenderDevice* pDevice, const CFX_AffineMatrix* pUser2Device, const CPDF_RenderOptions* pOptions)
 {