write 0 to our refcnt in the destructor, in the off-chance of it helping us
authorreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 12 Sep 2011 19:54:12 +0000 (19:54 +0000)
committerreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 12 Sep 2011 19:54:12 +0000 (19:54 +0000)
catch reuse-after-delete bugs (debug only)

git-svn-id: http://skia.googlecode.com/svn/trunk@2251 2bbb7eff-a529-9590-31e7-b0007b416f81

include/core/SkRefCnt.h

index 4c9376b..7af0017 100644 (file)
@@ -30,7 +30,12 @@ public:
 
     /**  Destruct, asserting that the reference count is 1.
     */
-    virtual ~SkRefCnt() { SkASSERT(fRefCnt == 1); }
+    virtual ~SkRefCnt() {
+#ifdef SK_DEBUG
+        SkASSERT(fRefCnt == 1);
+        fRefCnt = 0;    // illegal value, to catch us if we reuse after delete
+#endif
+    }
 
     /** Return the reference count.
     */