summaryrefslogtreecommitdiffstats
path: root/base/task.h
diff options
context:
space:
mode:
Diffstat (limited to 'base/task.h')
-rw-r--r--base/task.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/base/task.h b/base/task.h
index e9da8b3..0fb144b 100644
--- a/base/task.h
+++ b/base/task.h
@@ -221,6 +221,13 @@ struct RunnableMethodTraits {
}
void RetainCallee(T* obj) {
+#ifndef NDEBUG
+ // Catch NewRunnableMethod being called in an object's constructor. This
+ // isn't safe since the method can be invoked before the constructor
+ // completes, causing the object to be deleted.
+ obj->AddRef();
+ obj->Release();
+#endif
obj->AddRef();
}