-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Fix unchecked malloc #5431
Fix unchecked malloc #5431
Conversation
error:&error]); | ||
if (error) { | ||
FIRCLSErrorLog(@"Failed to read from %@ with error: %@", clsRecords[i], error); | ||
if (files != NULL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More of a style thing, but I like to keep the happy path code in the least-indent, and use if statements to check for issues and immediately return.
That way later code inside the method that may depend on files
being non-null doesn't have a chance to run.
Can we change this to:
if (files == NULL) {
return apple_payload;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
if (pbBytes != NULL) { | ||
memcpy(pbBytes->bytes, [data bytes], data.length); | ||
pbBytes->size = (pb_size_t)data.length; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here - can we just return NULL when pbBytes == null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a stylistic thing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix! 🛳
* Fix unchecked malloc * update changelogs * style * Code review comments
Fixes #5428.