Skip to content

Commit

Permalink
Merge 3e47aa9 into d257eb9
Browse files Browse the repository at this point in the history
  • Loading branch information
armcknight authored Apr 24, 2023
2 parents d257eb9 + 3e47aa9 commit 5a4e93a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- Ensure the current GPU frame rate is always reported for concurrent transaction profiling metrics (#2929)
- Possible crash in Core Data tracking (#2865)
- Convert one of the two remaining usages of `sprintf` to `snprintf` (#2866)

## 8.5.0

Expand Down
4 changes: 2 additions & 2 deletions Sources/SentryCrash/Recording/Tools/SentryCrashJSONCodec.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ sentrycrashjson_addUIntegerElement(
{
int result = sentrycrashjson_beginElement(context, name);
unlikely_if(result != SentryCrashJSON_OK) { return result; }
char buff[30];
sprintf(buff, "%" PRIu64, value);
char buff[50];
snprintf(buff, sizeof(buff), "%" PRIu64, value);
return addJSONData(context, buff, (int)strlen(buff));
}

Expand Down
16 changes: 16 additions & 0 deletions Tests/SentryTests/SentryCrash/SentryCrashJSONCodec_Tests.m
Original file line number Diff line number Diff line change
Expand Up @@ -1672,4 +1672,20 @@ - (void)testDontCloseLastContainer
return result;
}

- (void)testFastUIntEncode
{
char *expectedJson = "{\"uint\":1234567890}";

NSMutableData *encodedData = [NSMutableData data];
SentryCrashJSONEncodeContext context = { 0 };
sentrycrashjson_beginEncode(&context, false, addJSONData, (__bridge void *)(encodedData));
sentrycrashjson_beginObject(&context, NULL);
sentrycrashjson_addUIntegerElement(&context, "uint", 1234567890);
sentrycrashjson_endContainer(&context);
sentrycrashjson_endEncode(&context);
[encodedData appendBytes:"\0" length:1];

[self expectEquivalentJSON:encodedData.bytes toJSON:expectedJson];
}

@end

0 comments on commit 5a4e93a

Please sign in to comment.