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

Feature Request: malloc deallocate buffer in iOS SDK #718

Open
4 tasks done
wonhee-jeong opened this issue Apr 3, 2024 · 0 comments
Open
4 tasks done

Feature Request: malloc deallocate buffer in iOS SDK #718

wonhee-jeong opened this issue Apr 3, 2024 · 0 comments

Comments

@wonhee-jeong
Copy link

wonhee-jeong commented Apr 3, 2024

Checklist

  • I've updated to the latest released version of the SDK
  • I've searched for existing feature requests on GitHub issues
  • I've read the Code of Conduct
  • I've given my issue the title: Feature Request: [name of my feature request]

Goals

When returning a String from an iOS SDK function, it is returned as char*. The char* is a buffer allocated with malloc, but I can't find where to free it. Are there any memory leaks?
Isn't there a possibility of a memory leak in the iOS SDK functions?

Expected Results

Buffers allocated with malloc must be freed.

Code Samples & Details

char* IOSFBCurrentAuthenticationToken()
{
FBSDKAuthenticationToken *token = [FBSDKAuthenticationToken currentAuthenticationToken];
NSString *str = @"";
if (token.tokenString && token.nonce) {
try {
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:@{
@"auth_token_string": token.tokenString,
@"auth_nonce": token.nonce
} options:NSJSONWritingPrettyPrinted error:nil];
if (jsonData) {
str = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
}
} catch (NSException *exception) {
NSLog(@"Fail to parse AuthenticationToken");
}
}
const char* string = [str UTF8String];
char* res = (char*)malloc(strlen(string) + 1);
strcpy(res, string);
return res;
}

An example is the char* IOSFBCurrentAuthenticationToken(), char* IOSFBCurrentProfile(),char* IOSFBSdkVersion().. function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant