]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/scopedptr.h
fixing overrelease and out-of-bounds write, fixes #13725
[wxWidgets.git] / include / wx / scopedptr.h
index bfe98de16e5afc9c59f7b668e7b48bdd5b462b9e..f31a4ef036da529fe5399029fae1d0085b5c1e39 100644 (file)
@@ -63,7 +63,7 @@ public:
     {
         if ( ptr != m_ptr )
         {
-            delete m_ptr;
+            wxCHECKED_DELETE(m_ptr);
             m_ptr = ptr;
         }
     }
@@ -129,14 +129,7 @@ public:                             \
                                     \
     ~name();                        \
                                     \
-    void reset(T * ptr = NULL)      \
-    {                               \
-        if (m_ptr != ptr)           \
-        {                           \
-            delete m_ptr;           \
-            m_ptr = ptr;            \
-        }                           \
-    }                               \
+    void reset(T * ptr = NULL);     \
                                     \
     T *release()                    \
     {                               \
@@ -171,6 +164,14 @@ public:                             \
 };
 
 #define wxDEFINE_SCOPED_PTR(T, name)\
+void name::reset(T * ptr)           \
+{                                   \
+    if (m_ptr != ptr)               \
+    {                               \
+        wxCHECKED_DELETE(m_ptr);    \
+        m_ptr = ptr;                \
+    }                               \
+}                                   \
 name::~name()                       \
 {                                   \
     wxCHECKED_DELETE(m_ptr);        \