Fix double-free in DynamicConverter
Summary: If an exception is thrown during the construction of value in a container, then the Transformer iterator will not successfully reconstruct a cache_ object after explicitly calling its destructor (due to the exception being thrown), which results in a double-free when cache_ is destroyed as part of Transformer's destructor. Conveniently, there exists a piece of code designed to solve just this problem: folly::Optional. Replace cache_ and valid_ with folly::Optional. This also fixes the unnecessary requirement that container value types have default constructors, since cache_ is no longer default constructed inside of Transformer. Reviewed By: markisaa Differential Revision: D5472342 fbshipit-source-id: eade1f7ce260b9b3406d92af8255b5ffa4e4a51c
Showing
Please register or sign in to comment