diff options
author | Tom Sepez <tsepez@chromium.org> | 2017-05-16 15:33:20 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-05-16 23:26:47 +0000 |
commit | fe91c6c8211cec39f871d9202556e1957bf81983 (patch) | |
tree | b7e763f7affe4c71de67393fbd320c1fed477e0f /fpdfsdk/fpdfedittext.cpp | |
parent | 365333552cf67b7c97c4093177e7ed7b43f540ab (diff) | |
download | pdfium-fe91c6c8211cec39f871d9202556e1957bf81983.tar.xz |
Be skeptical of bare |new|s.
In particular, prefer an explicit .release() call when handing
ownership of an object to a caller across a C-API.
Change-Id: Ic3784e9d0b2d378a08d388989eaea7c9166bacd1
Reviewed-on: https://pdfium-review.googlesource.com/5470
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdfedittext.cpp')
-rw-r--r-- | fpdfsdk/fpdfedittext.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/fpdfsdk/fpdfedittext.cpp b/fpdfsdk/fpdfedittext.cpp index 54388ef701..c2f2df9778 100644 --- a/fpdfsdk/fpdfedittext.cpp +++ b/fpdfsdk/fpdfedittext.cpp @@ -388,11 +388,11 @@ DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPageObj_NewTextObj(FPDF_DOCUMENT document, if (!pFont) return nullptr; - CPDF_TextObject* pTextObj = new CPDF_TextObject; + auto pTextObj = pdfium::MakeUnique<CPDF_TextObject>(); pTextObj->m_TextState.SetFont(pFont); pTextObj->m_TextState.SetFontSize(font_size); pTextObj->DefaultStates(); - return pTextObj; + return pTextObj.release(); // Caller takes ownership. } DLLEXPORT FPDF_BOOL STDCALL FPDFText_SetText(FPDF_PAGEOBJECT text_object, |