robbiehanson / XMPPFramework

An XMPP Framework in Objective-C for Mac and iOS
Other
5.91k stars 2.09k forks source link

Fix crashes in XMPPvCardTempEmail and XMPPvCardTempTel initialize #1162

Closed beribas closed 4 years ago

beribas commented 4 years ago

Fixes #1050 and #1118.

Setter methods in XMPPcVardTempEmail and XMPPcVardTempTel had typing mistakes. Must have been happened sometime during 3.7 to 4.0 transition. These types do not allow adding properties, that's why the allocated size is compared to the size of NSXMLElement in initialize.

+ (void)initialize {
        // .....
    size_t superSize = class_getInstanceSize([NSXMLElement class]);
    size_t ourSize   = class_getInstanceSize([XMPPvCardTempEmail class]);

    if (superSize != ourSize)
    {
        XMPPLogError(@"Adding instance variables to XMPPvCardTempEmail is not currently supported!");

        [DDLog flushLog];
        exit(15);
    }
}

Every added property has to have matching get and set overwrites, otherwise ObjC will allocate memory for the property and the size check will fail. The linked issue describe that behavior.

I also added missing implementation for TEL and few tests for XMPPvCardTemp.

beribas commented 4 years ago

O yes, sure, didn't know about the XMLElement alias.

chrisballinger commented 4 years ago

Awesome, thank you!