aws-sdk-ios
aws-sdk-ios copied to clipboard
Likely crash in AWSMTLModel.m from property_getName returning nil
Not sure if this codepath is hit, but noticed this in an audit of a larger codebase.
https://github.com/aws/aws-sdk-ios/blob/e465aa8ed2f9051895c2b5865ec72b202a33d948/AWSCore/Mantle/AWSMTLModel.m#L149-L150
It's very possible for property_getName
to return nil which would cause the following exception:
NSInvalidArgumentException: *** -[__NSSetM addObject:]: object cannot be nil
You'll see that a few years back Mantle updated MTLModel, form which this is based off, to check against this function returning nil.
https://github.com/Mantle/Mantle/commit/c4812ac2b3c48a70fd339914f8e9f11d6c7b9f45#diff-34eb4dd8d9e1738c04c21a73f3fb8b0bL112
Hi @brynbodayle ,
Thanks for pointing this out. We will work on getting this incorporated.
It looks like the same check that prevents nil was moved in the new code. from https://github.com/Mantle/Mantle/commit/c4812ac2b3c48a70fd339914f8e9f11d6c7b9f45#diff-34eb4dd8d9e1738c04c21a73f3fb8b0bL109 to https://github.com/Mantle/Mantle/commit/c4812ac2b3c48a70fd339914f8e9f11d6c7b9f45#diff-34eb4dd8d9e1738c04c21a73f3fb8b0bR215
Core still has the check here https://github.com/aws/aws-sdk-ios/blob/e465aa8ed2f9051895c2b5865ec72b202a33d948/AWSCore/Mantle/AWSMTLModel.m#L147
@minbi We had this line in our codebase as well, but still were getting crashes https://github.com/aws/aws-sdk-ios/blob/e465aa8ed2f9051895c2b5865ec72b202a33d948/AWSCore/Mantle/AWSMTLModel.m#L147
There are a few other checks in MTLModel that guard against the case where the property name is nil. Sorry they weren't added until after that PR I sent you.
https://github.com/Mantle/Mantle/blob/master/Mantle/MTLModel.m#L227-L240
Closing this issue due to inactivity, feel free to re-open the issue with crash logs to help us debug further.