Chris Bracken a6917332f8 macOS: fix leak in CurrentKeyboardLayout (flutter/engine#56420)
Previously, if `layout_data` was not nil, we failed to `CFRelease` `source`. However, if `layout_data` was nil, we dif free source, then immediately set it to a new CoreFoundation object, which we then failed to free.

We now use `fml::CFRef` which just does the right thing.

Finally, we were returning `(__brdige_transfer)CFRetain(layout_data)` but `__bridge_transfer` releases the transferred object at the end of the enclosing expression, so this is equivalent to `(__bridge)layout_data`, which is what we now do.

No tests since this is a refactor with no semantic changes, other than fixing an internal leak.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
2024-11-07 16:45:19 +00:00
..