summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdf_transformpage.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-05-16 15:33:20 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-05-16 23:26:47 +0000
commitfe91c6c8211cec39f871d9202556e1957bf81983 (patch)
treeb7e763f7affe4c71de67393fbd320c1fed477e0f /fpdfsdk/fpdf_transformpage.cpp
parent365333552cf67b7c97c4093177e7ed7b43f540ab (diff)
downloadpdfium-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/fpdf_transformpage.cpp')
-rw-r--r--fpdfsdk/fpdf_transformpage.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/fpdfsdk/fpdf_transformpage.cpp b/fpdfsdk/fpdf_transformpage.cpp
index 32ba3a7525..cc5239b802 100644
--- a/fpdfsdk/fpdf_transformpage.cpp
+++ b/fpdfsdk/fpdf_transformpage.cpp
@@ -6,6 +6,7 @@
#include "public/fpdf_transformpage.h"
+#include <memory>
#include <vector>
#include "core/fpdfapi/page/cpdf_clippath.h"
@@ -222,13 +223,14 @@ DLLEXPORT FPDF_CLIPPATH STDCALL FPDF_CreateClipPath(float left,
CPDF_Path Path;
Path.AppendRect(left, bottom, right, top);
- CPDF_ClipPath* pNewClipPath = new CPDF_ClipPath();
+ auto pNewClipPath = pdfium::MakeUnique<CPDF_ClipPath>();
pNewClipPath->AppendPath(Path, FXFILL_ALTERNATE, false);
- return pNewClipPath;
+ return pNewClipPath.release(); // Caller takes ownership.
}
DLLEXPORT void STDCALL FPDF_DestroyClipPath(FPDF_CLIPPATH clipPath) {
- delete (CPDF_ClipPath*)clipPath;
+ // Take ownership back from caller and destroy.
+ std::unique_ptr<CPDF_ClipPath>(static_cast<CPDF_ClipPath*>(clipPath));
}
void OutputPath(CFX_ByteTextBuf& buf, CPDF_Path path) {