[poincare] Handle allocation failure in TreePool::deepCopy

This commit is contained in:
Léa Saviot
2018-07-25 17:00:21 +02:00
parent 3dcefa6a49
commit 31b34b93be

View File

@@ -42,6 +42,10 @@ public:
TreeNode * deepCopy(TreeNode * node) {
size_t size = node->deepSize();
void * ptr = alloc(size);
if (ptr == nullptr) {
node->failedAllocationStaticNode()->retain();
return node->failedAllocationStaticNode();
}
memcpy(ptr, static_cast<void *>(node), size);
TreeNode * copy = reinterpret_cast<TreeNode *>(ptr);
renameNode(copy);