Blender Git Loki
Git Commits -> Revision 5143a10
Revision 5143a10 by Ish Bosamiya (soc-2021-adaptive-cloth) July 7, 2021, 12:24 (GMT) |
adaptive_cloth: fix: add_empty_interp_element() crash sometimes Since the elements have a reference to the `Arena`, if the `Arena` changes in size, which can happen because of `add_empty_element()`, then the references can become invalid. Realloc can create memory space elsewhere and copy the contents, the references to the previous memory space are not updated which means references to the previous memory space are invalid. There are three ways to fix this: - Create a copy and work on the copy, this is inefficient - Get a reference to that element again, this is efficient but may not be possible always - Don't use the reference after an operation that can lead to the invalidation of the reference, this is the most efficient way but may not be possible always Decided to go with the third way in this case. Side note: Having a borrow checker completely eliminates such problems. Rust should be the way forward. |
Commit Details:
Full Hash: 5143a10288a67ab8e2a3ccf0232675004cb962a7
Parent Commit: 3e4a201
Lines Changed: +55, -4
1 Modified Path:
/source/blender/blenkernel/BKE_cloth_remesh.hh (+55, -4) (Diff)