Summary: Objective-C blocks are stack allocated, and unless there is a proper assignment it isn't retained and the memory is freed. Because folly::Function used to move, it would hold a reference, but after switch to a constructor by-value, it no longer does this and we see a use-after-free.
Reviewed By: yfeldblum, ericniebler
Differential Revision:
D5888606
fbshipit-source-id:
fe4cabb2f2ae289cce0e7429e0af3935ba314720
// not copyable
Function(const Function&) = delete;
+#if __OBJC__
+ // Delete conversion from Objective-C blocks
+ template <class ReturnType, class... Args>
+ Function(ReturnType (^)(Args...)) = delete;
+#endif
+
/**
* Move constructor
*/
Function& operator=(const Function&) = delete;
+#if __OBJC__
+ // Delete conversion from Objective-C blocks
+ template <class ReturnType, class... Args>
+ Function& operator=(ReturnType (^)(Args...)) = delete;
+#endif
+
/**
* Move assignment operator
*