Skip to content

Commit 65f4b4e

Browse files
Fix point/size/rect unpacking on 32-bit platforms
1 parent 5789b5a commit 65f4b4e

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

MessagePackCoder/MsgPackUnarchiver.m

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,10 @@ - (id)_unpackTypeAndObject
363363
}
364364

365365
case MsgPackArchiveTypePoint: {
366-
CGPoint p;
367-
UNPACK(_ctx, double, p.x, @"double");
368-
UNPACK(_ctx, double, p.y, @"double");
366+
double x, y;
367+
UNPACK(_ctx, double, x, @"double");
368+
UNPACK(_ctx, double, y, @"double");
369+
CGPoint p = CGPointMake(x, y);
369370
#if TARGET_OS_IPHONE
370371
object = [NSValue valueWithCGPoint:p];
371372
#else
@@ -375,9 +376,10 @@ - (id)_unpackTypeAndObject
375376
}
376377

377378
case MsgPackArchiveTypeSize: {
378-
CGSize size;
379-
UNPACK(_ctx, double, size.width, @"double");
380-
UNPACK(_ctx, double, size.height, @"double");
379+
double width, height;
380+
UNPACK(_ctx, double, width, @"double");
381+
UNPACK(_ctx, double, height, @"double");
382+
CGSize size = CGSizeMake(width, height);
381383
#if TARGET_OS_IPHONE
382384
object = [NSValue valueWithCGSize:size];
383385
#else
@@ -387,11 +389,12 @@ - (id)_unpackTypeAndObject
387389
}
388390

389391
case MsgPackArchiveTypeRect: {
390-
CGRect rect;
391-
UNPACK(_ctx, double, rect.origin.x, @"double");
392-
UNPACK(_ctx, double, rect.origin.y, @"double");
393-
UNPACK(_ctx, double, rect.size.width, @"double");
394-
UNPACK(_ctx, double, rect.size.height, @"double");
392+
double x, y, width, height;
393+
UNPACK(_ctx, double, x, @"double");
394+
UNPACK(_ctx, double, y, @"double");
395+
UNPACK(_ctx, double, width, @"double");
396+
UNPACK(_ctx, double, height, @"double");
397+
CGRect rect = CGRectMake(x, y, width, height);
395398
#if TARGET_OS_IPHONE
396399
object = [NSValue valueWithCGRect:rect];
397400
#else

0 commit comments

Comments
 (0)