Skip to content

Commit 096fc67

Browse files
authored
Fix calloc calls, which had the argument order reversed (#5218)
Also, maybe I should resign from software engineering
1 parent 94262b3 commit 096fc67

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Firebase/CoreDiagnostics/FIRCDLibrary/FIRCoreDiagnostics.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ + (NSString *)deviceModel {
236236
* @param data The data to copy into the new bytes array.
237237
*/
238238
pb_bytes_array_t *FIREncodeData(NSData *data) {
239-
pb_bytes_array_t *pbBytes = calloc(PB_BYTES_ARRAY_T_ALLOCSIZE(data.length), 1);
239+
pb_bytes_array_t *pbBytes = calloc(1, PB_BYTES_ARRAY_T_ALLOCSIZE(data.length));
240240
if (pbBytes != NULL) {
241241
[data getBytes:pbBytes range:NSMakeRange(0, data.length)];
242242
pbBytes->size = (pb_size_t)data.length;
@@ -510,8 +510,8 @@ void FIRPopulateProtoWithInstalledServices(logs_proto_mobilesdk_ios_ICoreConfigu
510510
}
511511

512512
logs_proto_mobilesdk_ios_ICoreConfiguration_ServiceType *servicesInstalled =
513-
calloc(sizeof(logs_proto_mobilesdk_ios_ICoreConfiguration_ServiceType),
514-
sdkServiceInstalledArray.count);
513+
calloc(sdkServiceInstalledArray.count,
514+
sizeof(logs_proto_mobilesdk_ios_ICoreConfiguration_ServiceType));
515515
if (servicesInstalled == NULL) {
516516
return;
517517
}

GoogleDataTransportCCTSupport/GDTCCTLibrary/GDTCCTNanopbHelpers.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
}
4444

4545
pb_bytes_array_t *GDTCCTEncodeData(NSData *data) {
46-
pb_bytes_array_t *pbBytes = calloc(PB_BYTES_ARRAY_T_ALLOCSIZE(data.length), 1);
46+
pb_bytes_array_t *pbBytes = calloc(1, PB_BYTES_ARRAY_T_ALLOCSIZE(data.length));
4747
if (pbBytes != NULL) {
4848
[data getBytes:pbBytes range:NSMakeRange(0, data.length)];
4949
pbBytes->size = (pb_size_t)data.length;
@@ -78,7 +78,7 @@ gdt_cct_BatchedLogRequest GDTCCTConstructBatchedLogRequest(
7878
NSDictionary<NSString *, NSSet<GDTCOREvent *> *> *logMappingIDToLogSet) {
7979
gdt_cct_BatchedLogRequest batchedLogRequest = gdt_cct_BatchedLogRequest_init_default;
8080
NSUInteger numberOfLogRequests = logMappingIDToLogSet.count;
81-
gdt_cct_LogRequest *logRequests = calloc(sizeof(gdt_cct_LogRequest), numberOfLogRequests);
81+
gdt_cct_LogRequest *logRequests = calloc(numberOfLogRequests, sizeof(gdt_cct_LogRequest));
8282
if (logRequests == NULL) {
8383
return batchedLogRequest;
8484
}
@@ -111,7 +111,7 @@ gdt_cct_LogRequest GDTCCTConstructLogRequest(int32_t logSource,
111111
logRequest.has_log_source = 1;
112112
logRequest.client_info = GDTCCTConstructClientInfo();
113113
logRequest.has_client_info = 1;
114-
logRequest.log_event = calloc(sizeof(gdt_cct_LogEvent), logSet.count);
114+
logRequest.log_event = calloc(logSet.count, sizeof(gdt_cct_LogEvent));
115115
if (logRequest.log_event == NULL) {
116116
return logRequest;
117117
}

0 commit comments

Comments
 (0)