Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Unified Diff: core/fpdfapi/page/cpdf_countedobject.h

Issue 2523743004: Ensure CPDF_CountedObjects only made from owned references. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | core/fpdfapi/page/cpdf_docpagedata.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfapi/page/cpdf_countedobject.h
diff --git a/core/fpdfapi/page/cpdf_countedobject.h b/core/fpdfapi/page/cpdf_countedobject.h
index 97d710cf76b173babfa9ef6866330f561d052848..64f936c52c4b0026bd3f5cb69a2f5cfa7ea85878 100644
--- a/core/fpdfapi/page/cpdf_countedobject.h
+++ b/core/fpdfapi/page/cpdf_countedobject.h
@@ -7,6 +7,8 @@
#ifndef CORE_FPDFAPI_PAGE_CPDF_COUNTEDOBJECT_H_
#define CORE_FPDFAPI_PAGE_CPDF_COUNTEDOBJECT_H_
+#include <memory>
+
#include "core/fpdfapi/page/cpdf_colorspace.h"
#include "core/fpdfapi/page/cpdf_pattern.h"
#include "core/fxcrt/fx_system.h"
@@ -14,10 +16,11 @@
template <class T>
class CPDF_CountedObject {
public:
- explicit CPDF_CountedObject(T* ptr) : m_nCount(1), m_pObj(ptr) {}
- void reset(T* ptr) { // CAUTION: tosses prior ref counts.
+ explicit CPDF_CountedObject(std::unique_ptr<T> ptr)
+ : m_nCount(1), m_pObj(ptr.release()) {}
+ void reset(std::unique_ptr<T> ptr) { // CAUTION: tosses prior ref counts.
m_nCount = 1;
- m_pObj = ptr;
+ m_pObj = ptr.release();
}
void clear() { // Now you're all weak ptrs ...
// Guard against accidental re-entry.
« no previous file with comments | « no previous file | core/fpdfapi/page/cpdf_docpagedata.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698