mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Issue: When using a densemap subscript expression on both sides of an assignment in the same statement of the same map we run into the issue that the map can reallocate because of the assignment but we are referencing the value of the RHS map subscript by reference -- i.e we can reference deallocated memory. Not good. Scope: A "silent" memory error that one might run into including the reporter of the bug. Risk: Extremely, low. The fix is spliting an assignment from a map value to a map entry into: A value assignment of the map value to a local. And then storing the local in the map entry forgoing the reference of reallocated memory bug. ``` valueMap[bfi] = valueMap[bfi->getBorrowedValue()]; => auto mappedMValue = valueMap[bfi->getBorrowedValue()]; valueMap[bfi] = mappedValue; ``` Reviewed by: Meghana G, Erik E., Joe G. Testing: The fix was tested on the reporting project. rdar://151031297
20 KiB
20 KiB