From ae877181636d08024ea14a9e27419f5f4a4d452b Mon Sep 17 00:00:00 2001 From: Andreas Coroiu Date: Tue, 23 Jul 2024 11:33:50 +0200 Subject: [PATCH] feat: add autoreleasepool to avoid memory leaks --- .../desktop_native/objc/src/native/autofill.m | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/apps/desktop/desktop_native/objc/src/native/autofill.m b/apps/desktop/desktop_native/objc/src/native/autofill.m index 351cf28b54..e73c804b50 100644 --- a/apps/desktop/desktop_native/objc/src/native/autofill.m +++ b/apps/desktop/desktop_native/objc/src/native/autofill.m @@ -46,15 +46,17 @@ void free_objc_string(struct ObjCString *value) { } struct ObjCString run_command(char* input_json) { - @try { - NSString *inputString = c_string_to_nsstring(input_json); + @autoreleasepool { + @try { + NSString *inputString = c_string_to_nsstring(input_json); - // NSString *outputString = [NSString stringWithFormat:@"{\"added\": %@}", e]; - NSString *outputString = @"{\"added\": 0}"; - return nsstring_to_obj_c_string(outputString); - } @catch (NSException *e) { - NSString *outputString = [NSString stringWithFormat:@"Error occurred while running Objective-C command: %@", e]; - return nsstring_to_obj_c_string(outputString); + // NSString *outputString = [NSString stringWithFormat:@"{\"added\": %@}", e]; + NSString *outputString = @"{\"added\": 0}"; + return nsstring_to_obj_c_string(outputString); + } @catch (NSException *e) { + NSString *outputString = [NSString stringWithFormat:@"Error occurred while running Objective-C command: %@", e]; + return nsstring_to_obj_c_string(outputString); + } } }