Change encoding/decoding to protect against differences in integer size.

This commit is contained in:
fredkiefer 2021-01-08 17:18:36 +01:00
parent 05572b2d01
commit 35698d41b6
12 changed files with 233 additions and 163 deletions

View file

@ -386,7 +386,10 @@ static Class controlClass;
}
else
{
[aCoder encodeValueOfObjCType: @encode(NSInteger) at: &_tag];
int32_t tmp;
tmp = _tag;
[aCoder encodeValueOfObjCType: @encode(int32_t) at: &tmp];
[aCoder encodeConditionalObject: _target];
[aCoder encodeValueOfObjCType: @encode(SEL) at: &_action];
// This is only encoded for backward compatibility and won't be decoded.
@ -419,12 +422,15 @@ static Class controlClass;
else
{
id dummy;
int32_t tmp;
[aDecoder decodeValueOfObjCType: @encode(NSInteger) at: &_tag];
[aDecoder decodeValueOfObjCType: @encode(int32_t) at: &tmp];
_tag = tmp;
_target = [aDecoder decodeObject];
[aDecoder decodeValueOfObjCType: @encode(SEL) at: &_action];
// Don't decode _control_view, as this may no longer be valid.
dummy = [aDecoder decodeObject];
[aDecoder decodeValueOfObjCType: @encode(id) at: &dummy];
RELEASE(dummy);
}
return self;