Skip to content

Commit bb3c51d

Browse files
Tzvetan Mikovfacebook-github-bot
authored andcommitted
RN: don't check for or add zero terminator to bundle (#45966)
Summary: Pull Request resolved: #45966 JSI performs the check itself, no need to do it here. Plus, bytecode bundles must not be zero terminated. ## Changelog: [IOS] [FIXED] - Fixes NSDataBigString length calculation Reviewed By: realsoelynn Differential Revision: D61058869 fbshipit-source-id: 15b99ef13f9aebd11ff410d02c21db8e46cc6ac3
1 parent 1f755de commit bb3c51d

File tree

1 file changed

+2
-25
lines changed

1 file changed

+2
-25
lines changed

packages/react-native/React/CxxBridge/NSDataBigString.mm

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,10 @@
99

1010
namespace facebook::react {
1111

12-
static NSData *ensureNullTerminated(NSData *source)
13-
{
14-
if (!source || source.length == 0) {
15-
return nil;
16-
}
17-
18-
NSUInteger sourceLength = source.length;
19-
unsigned char lastByte;
20-
[source getBytes:&lastByte range:NSMakeRange(sourceLength - 1, 1)];
21-
22-
// TODO: bundles from the packager should always include a NULL byte
23-
// or we should we relax this requirement and only read as much from the
24-
// buffer as length indicates
25-
if (lastByte == '\0') {
26-
return source;
27-
} else {
28-
NSMutableData *data = [source mutableCopy];
29-
unsigned char nullByte = '\0';
30-
[data appendBytes:&nullByte length:1];
31-
return data;
32-
}
33-
}
34-
3512
NSDataBigString::NSDataBigString(NSData *data)
3613
{
37-
m_length = [data length];
38-
m_data = ensureNullTerminated(data);
14+
m_data = data;
15+
m_length = [m_data length];
3916
}
4017

4118
} // namespace facebook::react

0 commit comments

Comments
 (0)