mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
fix(iOS): Properly retain/release backgroundColor in RCTBorderDrawing (#46797)
Summary: I discovered this while working on my shim of `UIGraphicsImageRenderer` for macOS (See https://github.com/microsoft/react-native-macos/pull/2209). A variable of type`CGColorRef` is not automatically retained and released when passed into a block. There was a case in `RCTBorderDrawing` where we were doing so. To fix this, we have two options: 1. Pass a `UIColor` instead (Requires a change to the signature of the function calling it) 2. Properly retain and release the variable. The first option would technically be a breaking change (we would need to change the signature of `RCTGetBorderImage`, so I'm opting for option 2. ## Changelog: [IOS] [FIXED] - Properly retain/release backgroundColor in RCTBorderDrawing Pull Request resolved: https://github.com/facebook/react-native/pull/46797 Test Plan: CI should pass. Locally, borders still draw fine for me. Reviewed By: joevilches Differential Revision: D63827824 Pulled By: cipolleschi fbshipit-source-id: 926601d062b90a7d741d7a1af3070cec4b8795ae
This commit is contained in:
committed by
Facebook GitHub Bot
parent
eeb6122f39
commit
47748c7935
@@ -232,6 +232,8 @@ static UIImage *RCTGetSolidBorderImage(
|
||||
|
||||
UIGraphicsImageRenderer *const imageRenderer =
|
||||
RCTMakeUIGraphicsImageRenderer(size, backgroundColor, hasCornerRadii, drawToEdge);
|
||||
|
||||
CGColorRetain(backgroundColor);
|
||||
UIImage *image = [imageRenderer imageWithActions:^(UIGraphicsImageRendererContext *_Nonnull rendererContext) {
|
||||
const CGContextRef context = rendererContext.CGContext;
|
||||
const CGRect rect = {.size = size};
|
||||
@@ -242,6 +244,7 @@ static UIImage *RCTGetSolidBorderImage(
|
||||
CGContextAddPath(context, path);
|
||||
CGContextFillPath(context);
|
||||
}
|
||||
CGColorRelease(backgroundColor);
|
||||
|
||||
CGContextAddPath(context, path);
|
||||
CGPathRelease(path);
|
||||
|
||||
Reference in New Issue
Block a user