Skip to content

Commit cde033a

Browse files
authored
Merge pull request #389 from Countly/fix_mem_acc
Fix invalid memory access while serializing the events
2 parents 5250393 + 1c3073d commit cde033a

File tree

9 files changed

+29
-25
lines changed

9 files changed

+29
-25
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 25.4.1
2+
* Mitigated an issue that could occur while serializing events to improve stability, performance and memory usage.
3+
14
## 25.4.0
25
* ! Minor breaking change ! Removed UIDevice.currentDevice.identifierForVendor usage in device id generation. The SDK now exclusively uses random UUIDs for device id generation.
36
* ! Minor breaking change ! Server Configuration is now enabled by default. Changes made on SDK Manager > SDK Configuration on your server will affect SDK behavior directly.

Countly-PL.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'Countly-PL'
3-
s.version = '25.4.0'
3+
s.version = '25.4.1'
44
s.license = { :type => 'MIT', :file => 'LICENSE' }
55
s.summary = 'Countly is an innovative, real-time, open source mobile analytics platform.'
66
s.homepage = 'https://github.com/Countly/countly-sdk-ios'

Countly.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'Countly'
3-
s.version = '25.4.0'
3+
s.version = '25.4.1'
44
s.license = { :type => 'MIT', :file => 'LICENSE' }
55
s.summary = 'Countly is an innovative, real-time, open source mobile analytics platform.'
66
s.homepage = 'https://github.com/Countly/countly-sdk-ios'

Countly.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@
760760
"@loader_path/Frameworks",
761761
);
762762
MACOSX_DEPLOYMENT_TARGET = 10.14;
763-
MARKETING_VERSION = 25.4.0;
763+
MARKETING_VERSION = 25.4.1;
764764
PRODUCT_BUNDLE_IDENTIFIER = ly.count.CountlyiOSSDK;
765765
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
766766
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -792,7 +792,7 @@
792792
"@loader_path/Frameworks",
793793
);
794794
MACOSX_DEPLOYMENT_TARGET = 10.14;
795-
MARKETING_VERSION = 25.4.0;
795+
MARKETING_VERSION = 25.4.1;
796796
PRODUCT_BUNDLE_IDENTIFIER = ly.count.CountlyiOSSDK;
797797
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
798798
PROVISIONING_PROFILE_SPECIFIER = "";

Countly.xcodeproj/xcshareddata/xcschemes/CountlyTests.xcscheme

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
</BuildAction>
99
<TestAction
1010
buildConfiguration = "Debug"
11-
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
12-
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
11+
selectedDebuggerIdentifier = ""
12+
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
1313
shouldUseLaunchSchemeArgsEnv = "YES">
1414
<TestPlans>
1515
<TestPlanReference

CountlyCommon.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ @interface CountlyCommon ()
2929
#endif
3030
@end
3131

32-
NSString* const kCountlySDKVersion = @"25.4.0";
32+
NSString* const kCountlySDKVersion = @"25.4.1";
3333
NSString* const kCountlySDKName = @"objc-native-ios";
3434

3535
NSString* const kCountlyErrorDomain = @"ly.count.ErrorDomain";

CountlyEvent.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ @implementation CountlyEvent
2121
NSString* const kCountlyEventKeyDayOfWeek = @"dow";
2222
NSString* const kCountlyEventKeyDuration = @"dur";
2323

24+
/**
25+
* This function is a critical component used within the `CountlyPersistency.serializeRecordedEvents` method.
26+
*
27+
* Note: If this function is modified, ensure that corresponding updates are made to
28+
* the `CountlyPersistency.serializeRecordedEvents` method to maintain consistency and prevent potential issues.
29+
*
30+
* @warning Changes to this function may have downstream effects. Proceed with caution.
31+
*/
2432
- (NSDictionary *)dictionaryRepresentation
2533
{
2634
NSMutableDictionary* eventData = NSMutableDictionary.dictionary;

CountlyPersistency.m

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -282,24 +282,17 @@ - (void)recordEvent:(CountlyEvent *)event
282282

283283
- (NSString *)serializedRecordedEvents
284284
{
285-
NSMutableArray *tempArray = NSMutableArray.new;
286-
287285
@synchronized (self.recordedEvents)
288286
{
289287
if (self.recordedEvents.count == 0)
290288
return nil;
291-
292-
NSArray *eventsCopy = self.recordedEvents.copy;
293-
294-
for (CountlyEvent *event in eventsCopy)
295-
{
296-
[tempArray addObject:[event dictionaryRepresentation]];
297-
}
298-
299-
[self.recordedEvents removeObjectsInArray:eventsCopy];
289+
290+
NSArray *eventDictionaries = [self.recordedEvents valueForKey:@"dictionaryRepresentation"];
291+
292+
[self.recordedEvents removeAllObjects];
293+
294+
return [eventDictionaries cly_JSONify];
300295
}
301-
302-
return [tempArray cly_JSONify];
303296
}
304297

305298

CountlyTests/CountlyDeviceIDTests.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,13 @@ class CountlyDeviceIDTests: CountlyBaseTestCase {
116116
}
117117

118118
func getIDFV() -> String {
119-
var UUID = CountlyPersistency.sharedInstance().retrieveNSUUID()
120-
if UUID == nil {
121-
UUID = UUID().uuidString
122-
CountlyPersistency.sharedInstance().storeNSUUID(UUID)
119+
var uuid = CountlyPersistency.sharedInstance().retrieveNSUUID()
120+
if uuid == nil {
121+
uuid = UUID().uuidString
122+
CountlyPersistency.sharedInstance().storeNSUUID(uuid)
123123
}
124124

125-
return UUID ?? ""
125+
return uuid ?? ""
126126
}
127127

128128
}

0 commit comments

Comments
 (0)