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

[SDLRPCStruct initWithDictionary] does not check for a nil dictionary #76

Closed
jacobkeeler opened this issue Feb 10, 2015 · 1 comment
Closed
Labels
bug A defect in the library

Comments

@jacobkeeler
Copy link

In [SDLRPCStruct initWithDictionary], there is no check whether the passed in dictionary is nil.

-(id) initWithDictionary:(NSMutableDictionary*) dict {
    if (self = [super init]) {
        store = dict;
    }
    return self;
}

This means that if any such object is initialized with a nil dictionary, then its properties cannot be edited.

There should be a check to see whether the passed in dictionary is nil, and if it is, then store should just be initialized with an empty dictionary.

-(id) initWithDictionary:(NSMutableDictionary*) dict {
    if (self = [super init]) {
        if (dict == nil) {
            store = [[NSMutableDictionary alloc] init];
        } else {
            store = dict;
        }
    }
    return self;
}

See also: #75

@joeljfischer joeljfischer added the bug A defect in the library label Feb 10, 2015
@joeljfischer joeljfischer added this to the 4.1.0 milestone Apr 15, 2015
@joeljfischer joeljfischer modified the milestones: 4.0.1, 4.1.0 Jul 31, 2015
@joeljfischer
Copy link
Contributor

Could use -initWithDictionary which if passed nil will create an empty dict.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A defect in the library
Projects
None yet
Development

No branches or pull requests

2 participants