react-native
react-native copied to clipboard
add missing struct member initialization for struct in Props.hj
Summary: Problem:
It was discovered while testing 3 party library, generated member variables in a C++ struct
in Props.h
is not initialized.
For the problematic case it was a boolean
but would also apply to other primitive types.
If there is no default initialization and the component prop is optional and the user of the native component does not set the prop then the variable is never initialized and this is problematic for primitive types in C++ where no initialization results in an undefined behavior.
Proposed solution:
(Following C++Core Guideline of always initialize.)
Reusing generatePropsString()
used by ClassTemplate
to generate props for StructTemplate
as well.
updated relevant test snapshots.
This change is only concerning the Props.h
file.
Differential Revision: D56659457
Platform | Engine | Arch | Size (bytes) | Diff |
---|---|---|---|---|
android | hermes | arm64-v8a | 19,444,929 | -80 |
android | hermes | armeabi-v7a | n/a | -- |
android | hermes | x86 | n/a | -- |
android | hermes | x86_64 | n/a | -- |
android | jsc | arm64-v8a | 22,817,866 | +3 |
android | jsc | armeabi-v7a | n/a | -- |
android | jsc | x86 | n/a | -- |
android | jsc | x86_64 | n/a | -- |
Base commit: ab00a453a827a419ce147d80d2679b324c219143 Branch: main
This pull request has been merged in facebook/react-native@639d890dff49af788fbe27c60b33f6025ec33cca.
This pull request was successfully merged by @alanleedev in 639d890dff49af788fbe27c60b33f6025ec33cca.
When will my fix make it into a release? | How to file a pick request?