Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use UInts in envelope deserialization #4441

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ via the option `swizzleClassNameExclude`.
- Swizzling RootUIViewController if ignored by `swizzleClassNameExclude` (#4407)
- Data race in SentrySwizzleInfo.originalCalled (#4434)


### Improvements

- Serializing profile on a BG Thread (#4377) to avoid potentially slightly blocking the main thread.
- Session Replay performance for SwiftUI (#4419)
- Speed up getBinaryImages (#4435) for finishing transactions and capturing events
- Use UInts in envelope deserialization (#4441)

## 8.38.0-beta.1

Expand Down
8 changes: 4 additions & 4 deletions Sources/Sentry/SentrySerialization.m
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ + (SentryEnvelope *_Nullable)envelopeWithData:(NSData *)data
{
SentryEnvelopeHeader *envelopeHeader = nil;
const unsigned char *bytes = [data bytes];
int envelopeHeaderIndex = 0;
NSUInteger envelopeHeaderIndex = 0;

for (int i = 0; i < data.length; ++i) {
for (NSUInteger i = 0; i < data.length; ++i) {
if (bytes[i] == '\n') {
envelopeHeaderIndex = i;
// Envelope header end
Expand Down Expand Up @@ -142,12 +142,12 @@ + (SentryEnvelope *_Nullable)envelopeWithData:(NSData *)data
}

// Parse items
NSInteger itemHeaderStart = envelopeHeaderIndex + 1;
NSUInteger itemHeaderStart = envelopeHeaderIndex + 1;

NSMutableArray<SentryEnvelopeItem *> *items = [NSMutableArray new];
NSUInteger endOfEnvelope = data.length - 1;

for (NSInteger i = itemHeaderStart; i <= endOfEnvelope; ++i) {
for (NSUInteger i = itemHeaderStart; i <= endOfEnvelope; ++i) {
if (bytes[i] == '\n' || i == endOfEnvelope) {

NSData *itemHeaderData =
Expand Down
Loading