Skip to content

Poor errors handling and memory management #17

@dodikk

Description

@dodikk

For example :

- (NSSet *)protocols {
    if (!_protocols) {
        Protocol *__unsafe_unretained *protocols;
        uint protocolsCount = 0;
        protocols = class_copyProtocolList(_objcClass, &protocolsCount);
        NSMutableSet *mutableProtocols = [NSMutableSet setWithCapacity:protocolsCount];
        for (uint protocolIndex = 0; protocolIndex != protocolsCount; ++protocolIndex) {
            Protocol *protocol = protocols[protocolIndex];
            [mutableProtocols addObject:protocol];
        }

// What makes you sure "protocols" variable is not NULL ?
free(protocols);

        _protocols = [NSSet setWithSet:mutableProtocols];
    }
    return _protocols;
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions